service/app/mix/controller/media.go

82 lines
2.1 KiB
Go

package controller
import (
"service/api/errcode"
mediaproto "service/api/proto/media/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"github.com/gin-gonic/gin"
)
// 获取签名
func MediaAuth(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*mediaproto.MediaAuthReq)
policyToken, ec := service.DefaultService.MediaAuth(ctx, req)
if ec != errcode.ErrCodeMediaSrvOk {
logger.Error("OpUpdateProduct fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &mediaproto.MediaAuthData{
PolicyToken: policyToken,
}
ReplyOk(ctx, data)
}
// 上传媒体
func CUpload(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*mediaproto.CUploadReq)
ret, ec := service.DefaultService.CUpload(ctx, req)
if ec != errcode.ErrCodeMediaSrvOk {
logger.Error("CUpload fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &mediaproto.CUploadData{
RetItem: ret,
}
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)
}
func OpUpdateVideoPF(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*mediaproto.OpUpdateVideoPFReq)
ec := service.DefaultService.OpUpdateVideoPF(ctx, req)
if ec != errcode.ErrCodeMediaSrvOk {
logger.Error("OpUpdateVideoPF fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}