2024-03-21 23:26:23 +08:00
|
|
|
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"
|
2024-04-03 06:19:11 +08:00
|
|
|
"service/library/mediafiller"
|
2024-03-21 23:26:23 +08:00
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ApiCreateZoneMoment(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*zonemomentproto.ApiCreateReq)
|
2024-04-02 22:47:41 +08:00
|
|
|
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
|
|
|
|
}
|
2024-03-21 23:26:23 +08:00
|
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
2024-04-02 22:47:41 +08:00
|
|
|
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
2024-03-21 23:26:23 +08:00
|
|
|
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)
|
2024-04-04 20:48:42 +08:00
|
|
|
ec := service.DefaultService.ApiDeleteZoneMoment(ctx, req)
|
2024-03-21 23:26:23 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-04-03 00:25:14 +08:00
|
|
|
list, ec := service.DefaultService.ApiGetZoneMomentListByVisitorMid(ctx, req)
|
2024-03-21 23:26:23 +08:00
|
|
|
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
|
|
|
logger.Error("ApiGetZoneMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-04-05 19:23:36 +08:00
|
|
|
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
|
2024-04-03 06:19:11 +08:00
|
|
|
}
|
|
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
|
2024-03-21 23:26:23 +08:00
|
|
|
data := &zonemomentproto.ApiListByVisitorMidData{
|
|
|
|
List: list,
|
|
|
|
Offset: req.Offset + len(list),
|
|
|
|
}
|
|
|
|
if len(list) >= req.Limit {
|
|
|
|
data.More = 1
|
|
|
|
}
|
|
|
|
ReplyOk(ctx, data)
|
|
|
|
}
|
|
|
|
|
2024-04-03 00:25:14 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-04-05 19:23:36 +08:00
|
|
|
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
|
2024-04-03 06:19:11 +08:00
|
|
|
}
|
|
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
2024-08-01 20:22:48 +08:00
|
|
|
service.DefaultService.UtilEncryptVideosForZoneMomentVOs(ctx, list)
|
2024-04-03 06:19:11 +08:00
|
|
|
|
2024-04-03 00:25:14 +08:00
|
|
|
data := &zonemomentproto.ApiListByCreaterMidData{
|
|
|
|
List: list,
|
|
|
|
Offset: req.Offset + len(list),
|
|
|
|
}
|
|
|
|
if len(list) >= req.Limit {
|
|
|
|
data.More = 1
|
|
|
|
}
|
|
|
|
ReplyOk(ctx, data)
|
|
|
|
}
|
|
|
|
|
2024-04-04 20:48:42 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-04-05 19:23:36 +08:00
|
|
|
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
|
2024-04-04 20:48:42 +08:00
|
|
|
}
|
|
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
2024-08-01 20:22:48 +08:00
|
|
|
service.DefaultService.UtilEncryptVideosForZoneMomentVOs(ctx, list)
|
2024-04-04 20:48:42 +08:00
|
|
|
|
|
|
|
data := &zonemomentproto.ApiListByZidData{
|
|
|
|
List: list,
|
|
|
|
Offset: req.Offset + len(list),
|
|
|
|
}
|
|
|
|
if len(list) >= req.Limit {
|
|
|
|
data.More = 1
|
|
|
|
}
|
|
|
|
ReplyOk(ctx, data)
|
|
|
|
}
|
|
|
|
|
2024-03-21 23:26:23 +08:00
|
|
|
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)
|
|
|
|
}
|
2024-04-11 15:46:01 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2024-04-11 19:34:51 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|