merge
This commit is contained in:
commit
f247f2ddc1
|
@ -1,6 +1,9 @@
|
||||||
package proto
|
package proto
|
||||||
|
|
||||||
import "service/api/base"
|
import (
|
||||||
|
"service/api/base"
|
||||||
|
"service/dbstruct"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MediaTypeImg = 1 // 图片
|
MediaTypeImg = 1 // 图片
|
||||||
|
@ -75,3 +78,29 @@ type VideoListResp struct {
|
||||||
base.BaseResponse
|
base.BaseResponse
|
||||||
Data *VideoListData `json:"data"`
|
Data *VideoListData `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// op
|
||||||
|
type OpGetVideosByStatusReq struct {
|
||||||
|
Ids []int64 `json:"ids"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
Offset int `json:"offset"`
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpGetVideosByStatusData struct {
|
||||||
|
List []*dbstruct.Video `json:"video"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新压缩后的视频
|
||||||
|
type OpUpdateVideoCompressReq struct {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
SizeSrc int64 `json:"size_src"` // 原视频大小
|
||||||
|
SrcId720 string `json:"src_id_720"` // 720P视频
|
||||||
|
Size720 int64 `json:"size_720"` // 720P视频大小
|
||||||
|
SrcIdH264 string `json:"src_id_h264"` // 原视频h264 mp4
|
||||||
|
SizeH264 int64 `json:"size_h264"` // 原视频h264 mp4大小
|
||||||
|
Status int `json:"status"` // 状态
|
||||||
|
ResizeT int64 `json:"resize_t"` // 压缩时间
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpUpdateVideoCompressData struct{}
|
||||||
|
|
|
@ -454,6 +454,10 @@ func Init(r *gin.Engine) {
|
||||||
mediaGroup.POST("auth", middleware.JSONParamValidator(mediaproto.MediaAuthReq{}), middleware.JwtAuthenticator(), MediaAuth)
|
mediaGroup.POST("auth", middleware.JSONParamValidator(mediaproto.MediaAuthReq{}), middleware.JwtAuthenticator(), MediaAuth)
|
||||||
mediaGroup.POST("c_upload", middleware.JSONParamValidator(mediaproto.CUploadReq{}), middleware.JwtAuthenticator(), CUpload)
|
mediaGroup.POST("c_upload", middleware.JSONParamValidator(mediaproto.CUploadReq{}), middleware.JwtAuthenticator(), CUpload)
|
||||||
|
|
||||||
|
opMediaGroup := r.Group("/op/media", PrepareToC())
|
||||||
|
opMediaGroup.POST("get_videos_by_status", middleware.JSONParamValidator(mediaproto.OpGetVideosByStatusReq{}), OpGetVideosByStatus)
|
||||||
|
opMediaGroup.POST("update_video_compress", middleware.JSONParamValidator(mediaproto.OpUpdateVideoCompressReq{}), OpUpdateVideoCompress)
|
||||||
|
|
||||||
// 主播标签
|
// 主播标签
|
||||||
opStreamerTagGroup := r.Group("/op/streamer_tag", PrepareOp())
|
opStreamerTagGroup := r.Group("/op/streamer_tag", PrepareOp())
|
||||||
opStreamerTagGroup.POST("list", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), OpGetStreamerTagList)
|
opStreamerTagGroup.POST("list", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), OpGetStreamerTagList)
|
||||||
|
@ -514,12 +518,6 @@ func Init(r *gin.Engine) {
|
||||||
// 视频审核callback
|
// 视频审核callback
|
||||||
extVideoModerationGroup := r.Group("/ext/video_moderation")
|
extVideoModerationGroup := r.Group("/ext/video_moderation")
|
||||||
extVideoModerationGroup.POST("callback", middleware.FORMParamValidator(video_moderation_proto.ExtVideoModerationReq{}), VideoModerationCallback)
|
extVideoModerationGroup.POST("callback", middleware.FORMParamValidator(video_moderation_proto.ExtVideoModerationReq{}), VideoModerationCallback)
|
||||||
|
|
||||||
// 账号相关
|
|
||||||
//accountGroup := r.Group("/account")
|
|
||||||
|
|
||||||
// =============================== 以上是服务,只允许内网调用 ===============================
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ServeFile(ctx *gin.Context) {
|
func ServeFile(ctx *gin.Context) {
|
||||||
|
|
|
@ -41,3 +41,30 @@ func CUpload(ctx *gin.Context) {
|
||||||
}
|
}
|
||||||
ReplyOk(ctx, data)
|
ReplyOk(ctx, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取待压缩的视频
|
||||||
|
func OpGetVideosByStatus(ctx *gin.Context) {
|
||||||
|
req := ctx.MustGet("client_req").(*mediaproto.OpGetVideosByStatusReq)
|
||||||
|
list, ec := service.DefaultService.GetVideosByStatus(ctx, req)
|
||||||
|
if ec != errcode.ErrCodeMediaSrvOk {
|
||||||
|
logger.Error("GetVideosByStatus fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||||
|
ReplyErrCodeMsg(ctx, ec)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data := &mediaproto.OpGetVideosByStatusData{
|
||||||
|
List: list,
|
||||||
|
}
|
||||||
|
ReplyOk(ctx, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func OpUpdateVideoCompress(ctx *gin.Context) {
|
||||||
|
req := ctx.MustGet("client_req").(*mediaproto.OpUpdateVideoCompressReq)
|
||||||
|
ec := service.DefaultService.OpUpdateVideoCompress(ctx, req)
|
||||||
|
if ec != errcode.ErrCodeMediaSrvOk {
|
||||||
|
logger.Error("OpUpdateVideoCompress fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||||
|
ReplyErrCodeMsg(ctx, ec)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ReplyOk(ctx, nil)
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"service/api/consts"
|
"service/api/consts"
|
||||||
bannerproto "service/api/proto/banner/proto"
|
bannerproto "service/api/proto/banner/proto"
|
||||||
catalogproto "service/api/proto/catalog/proto"
|
catalogproto "service/api/proto/catalog/proto"
|
||||||
|
mediaproto "service/api/proto/media/proto"
|
||||||
"service/bizcommon/common"
|
"service/bizcommon/common"
|
||||||
"service/bizcommon/util"
|
"service/bizcommon/util"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -933,6 +934,33 @@ func (m *Mongo) GetVideoByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.Video,
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Mongo) GetVideoByStatus(ctx *gin.Context, status, offset, limit int) ([]*dbstruct.Video, error) {
|
||||||
|
list := make([]*dbstruct.Video, 0)
|
||||||
|
col := m.getColVideo()
|
||||||
|
err := col.Find(ctx, qmgo.M{"status": status}).Skip(int64(offset)).Limit(int64(limit)).All(&list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Mongo) UpdateVideoCompress(ctx *gin.Context, req *mediaproto.OpUpdateVideoCompressReq) error {
|
||||||
|
col := m.getColVideo()
|
||||||
|
set := qmgo.M{
|
||||||
|
"size_src": req.SizeSrc,
|
||||||
|
"src_id_720": req.SrcId720,
|
||||||
|
"size_720": req.Size720,
|
||||||
|
"src_id_h264": req.SrcIdH264,
|
||||||
|
"size_h264": req.SizeH264,
|
||||||
|
"status": req.Status,
|
||||||
|
"resize_t": req.ResizeT,
|
||||||
|
}
|
||||||
|
up := qmgo.M{
|
||||||
|
"$set": set,
|
||||||
|
}
|
||||||
|
return col.UpdateId(ctx, req.Id, up)
|
||||||
|
}
|
||||||
|
|
||||||
// 登录表
|
// 登录表
|
||||||
func (m *Mongo) CreateLogin(ctx *gin.Context, login *dbstruct.Login) error {
|
func (m *Mongo) CreateLogin(ctx *gin.Context, login *dbstruct.Login) error {
|
||||||
col := m.getColLogin()
|
col := m.getColLogin()
|
||||||
|
|
|
@ -259,3 +259,19 @@ func (m *Media) GetVideoByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.Video,
|
||||||
}
|
}
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Media) OpGetVideosByStatus(ctx *gin.Context, req *mediaproto.OpGetVideosByStatusReq) ([]*dbstruct.Video, error) {
|
||||||
|
if len(req.Ids) > 0 {
|
||||||
|
return m.store.GetVideoByIds(ctx, req.Ids)
|
||||||
|
}
|
||||||
|
list, err := m.store.GetVideoByStatus(ctx, req.Status, req.Offset, req.Limit)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("GetVideoByStatus fail, req: %v, err: %v", util.ToJson(req), err)
|
||||||
|
return make([]*dbstruct.Video, 0), err
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Media) OpUpdateVideoCompress(ctx *gin.Context, req *mediaproto.OpUpdateVideoCompressReq) error {
|
||||||
|
return m.store.UpdateVideoCompress(ctx, req)
|
||||||
|
}
|
||||||
|
|
|
@ -2466,6 +2466,28 @@ func (s *Service) GetVideoByIds(ctx *gin.Context, req *mediaproto.VideoListReq)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Service) GetVideosByStatus(ctx *gin.Context, req *mediaproto.OpGetVideosByStatusReq) (list []*dbstruct.Video, ec errcode.ErrCode) {
|
||||||
|
ec = errcode.ErrCodeMediaSrvOk
|
||||||
|
list, err := _DefaultMedia.OpGetVideosByStatus(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("OpGetVideosByStatus fail, req: %v, err: %v", util.ToJson(req), err)
|
||||||
|
ec = errcode.ErrCodeMediaSrvFail
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) OpUpdateVideoCompress(ctx *gin.Context, req *mediaproto.OpUpdateVideoCompressReq) (ec errcode.ErrCode) {
|
||||||
|
ec = errcode.ErrCodeMediaSrvOk
|
||||||
|
err := _DefaultMedia.OpUpdateVideoCompress(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("OpUpdateVideoCompress fail, req: %v, err: %v", util.ToJson(req), err)
|
||||||
|
ec = errcode.ErrCodeMediaSrvFail
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Service) OpGetPlatformListByIds(ctx *gin.Context, ids []int64) (list []*apollostruct.PlatformCfg, ec errcode.ErrCode) {
|
func (s *Service) OpGetPlatformListByIds(ctx *gin.Context, ids []int64) (list []*apollostruct.PlatformCfg, ec errcode.ErrCode) {
|
||||||
|
|
||||||
ec = errcode.ErrCodeOk
|
ec = errcode.ErrCodeOk
|
||||||
|
|
|
@ -12,6 +12,13 @@ const (
|
||||||
ImageStatusResizeFail = 101
|
ImageStatusResizeFail = 101
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 视频
|
||||||
|
const (
|
||||||
|
VideoStatusResizeInit = 0
|
||||||
|
VideoStatusResizeDone = 100
|
||||||
|
VideoStatusResizeFail = 101
|
||||||
|
)
|
||||||
|
|
||||||
type Image struct {
|
type Image struct {
|
||||||
Id int64 `json:"id" bson:"_id"` // 图片id
|
Id int64 `json:"id" bson:"_id"` // 图片id
|
||||||
Ct int64 `json:"ct" bson:"ct"` // 创建时间
|
Ct int64 `json:"ct" bson:"ct"` // 创建时间
|
||||||
|
@ -56,6 +63,13 @@ type Video struct {
|
||||||
Ct int64 `json:"ct" bson:"ct"` // 创建时间
|
Ct int64 `json:"ct" bson:"ct"` // 创建时间
|
||||||
Ut int64 `json:"ut" bson:"ut"` // 更新时间
|
Ut int64 `json:"ut" bson:"ut"` // 更新时间
|
||||||
SrcId string `json:"src_id" bson:"src_id"` // 源id
|
SrcId string `json:"src_id" bson:"src_id"` // 源id
|
||||||
|
SizeSrc int64 `json:"size_src" bson:"size_src"` // 原视频大小
|
||||||
|
SrcId720 string `json:"src_id_720" bson:"src_id_720"` // 720P视频
|
||||||
|
Size720 int64 `json:"size_720" bson:"size_720"` // 720P视频大小
|
||||||
|
SrcIdH264 string `json:"src_id_h264" bson:"src_id_h264"` // 原视频h264 mp4
|
||||||
|
SizeH264 int64 `json:"size_h264" bson:"size_h264"` // 原视频h264 mp4大小
|
||||||
|
Status int `json:"status" bson:"status"` // 状态
|
||||||
|
ResizeT int64 `json:"resize_t" bson:"resize_t"` // 压缩时间
|
||||||
CoverSrcId string `json:"cover_src_id" bson:"cover_src_id"` // cover srcId
|
CoverSrcId string `json:"cover_src_id" bson:"cover_src_id"` // cover srcId
|
||||||
CoverId int64 `json:"cover_id" bson:"cover_id"` // 封面id
|
CoverId int64 `json:"cover_id" bson:"cover_id"` // 封面id
|
||||||
MD5 string `json:"md5" bson:"md5"` // 视频md5
|
MD5 string `json:"md5" bson:"md5"` // 视频md5
|
||||||
|
|
Loading…
Reference in New Issue