202 lines
6.2 KiB
Go
202 lines
6.2 KiB
Go
package controller
|
|
|
|
import (
|
|
"service/api/consts"
|
|
"service/api/errcode"
|
|
zonemomentproto "service/api/proto/zonemoment/proto"
|
|
"service/app/mix/service"
|
|
"service/bizcommon/util"
|
|
"service/library/logger"
|
|
"service/library/mediafiller"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func ApiCreateZoneMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiCreateReq)
|
|
ec, acctPunEndTime := service.DefaultService.ApiCreateZoneMoment(ctx, req)
|
|
if ec == errcode.ErrCodeFunctionBlocked {
|
|
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsgAndDetail(ctx, ec, acctPunEndTime)
|
|
return
|
|
}
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func ApiUpdateZoneMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiUpdateReq)
|
|
ec := service.DefaultService.ApiUpdateZoneMoment(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("ApiUpdateZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func ApiDeleteZoneMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiDeleteReq)
|
|
ec := service.DefaultService.ApiDeleteZoneMoment(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("ApiDeleteZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func ApiGetZoneMomentListByVisitorMid(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiListByVisitorMidReq)
|
|
|
|
//设置默认页长
|
|
if req.Limit == 0 {
|
|
req.Limit = consts.DefaultPageSize
|
|
}
|
|
|
|
list, ec := service.DefaultService.ApiGetZoneMomentListByVisitorMid(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("ApiGetZoneMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
objectMediaNum := 5 // 单个空间贴服务总共5个媒体类
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
|
|
for i, vo := range list {
|
|
mediaFillableList[objectMediaNum*i+0] = vo.ZoneMoment.MediaComp
|
|
mediaFillableList[objectMediaNum*i+1] = vo.StreamerExt.Cover
|
|
mediaFillableList[objectMediaNum*i+2] = vo.StreamerExt.Shorts
|
|
mediaFillableList[objectMediaNum*i+3] = vo.StreamerExt.Album
|
|
mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar
|
|
}
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
data := &zonemomentproto.ApiListByVisitorMidData{
|
|
List: list,
|
|
Offset: req.Offset + len(list),
|
|
}
|
|
if len(list) >= req.Limit {
|
|
data.More = 1
|
|
}
|
|
ReplyOk(ctx, data)
|
|
}
|
|
|
|
func ApiGetZoneMomentListByCreaterMid(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiListByCreaterMidReq)
|
|
|
|
//设置默认页长
|
|
if req.Limit == 0 {
|
|
req.Limit = consts.DefaultPageSize
|
|
}
|
|
|
|
list, ec := service.DefaultService.ApiGetZoneMomentListByCreaterMid(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("ApiGetZoneMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
objectMediaNum := 5 // 单个空间贴服务总共5个媒体类
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
|
|
for i, vo := range list {
|
|
mediaFillableList[objectMediaNum*i+0] = vo.ZoneMoment.MediaComp
|
|
mediaFillableList[objectMediaNum*i+1] = vo.StreamerExt.Cover
|
|
mediaFillableList[objectMediaNum*i+2] = vo.StreamerExt.Shorts
|
|
mediaFillableList[objectMediaNum*i+3] = vo.StreamerExt.Album
|
|
mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar
|
|
}
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
service.DefaultService.UtilEncryptVideosForZoneMomentVOs(ctx, list)
|
|
|
|
data := &zonemomentproto.ApiListByCreaterMidData{
|
|
List: list,
|
|
Offset: req.Offset + len(list),
|
|
}
|
|
if len(list) >= req.Limit {
|
|
data.More = 1
|
|
}
|
|
ReplyOk(ctx, data)
|
|
}
|
|
|
|
func ApiGetZoneMomentListByZid(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiListByZidReq)
|
|
|
|
//设置默认页长
|
|
if req.Limit == 0 {
|
|
req.Limit = consts.DefaultPageSize
|
|
}
|
|
|
|
list, ec := service.DefaultService.ApiGetZoneMomentListByZid(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("ApiGetZoneMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
objectMediaNum := 5 // 单个空间贴服务总共5个媒体类
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
|
|
for i, vo := range list {
|
|
mediaFillableList[objectMediaNum*i+0] = vo.ZoneMoment.MediaComp
|
|
mediaFillableList[objectMediaNum*i+1] = vo.StreamerExt.Cover
|
|
mediaFillableList[objectMediaNum*i+2] = vo.StreamerExt.Shorts
|
|
mediaFillableList[objectMediaNum*i+3] = vo.StreamerExt.Album
|
|
mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar
|
|
}
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
service.DefaultService.UtilEncryptVideosForZoneMomentVOs(ctx, list)
|
|
|
|
data := &zonemomentproto.ApiListByZidData{
|
|
List: list,
|
|
Offset: req.Offset + len(list),
|
|
}
|
|
if len(list) >= req.Limit {
|
|
data.More = 1
|
|
}
|
|
ReplyOk(ctx, data)
|
|
}
|
|
|
|
func ApiZoneMomentThumbsUpMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiZoneMomentThumbsUpReq)
|
|
ec := service.DefaultService.ApiZoneMomentThumbsUpMoment(ctx, req)
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
logger.Error("ApiZoneMomentThumbsUpMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func ApiHeadZoneMoment(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiHeadReq)
|
|
ec := service.DefaultService.ApiHeadZoneMoment(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("ApiHeadZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func ApiGetZoneMomentStatisticsByCreaterMid(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiListStatisticsByCreaterMidReq)
|
|
|
|
data, ec := service.DefaultService.ApiGetZoneMomentStatisticsByCreaterMid(ctx, req)
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
logger.Error("ApiGetZoneMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, data)
|
|
}
|