2023-12-21 22:17:40 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"service/api/consts"
|
|
|
|
"service/api/errcode"
|
|
|
|
momentproto "service/api/proto/moment/proto"
|
|
|
|
"service/app/mix/service"
|
|
|
|
"service/bizcommon/util"
|
|
|
|
"service/library/logger"
|
|
|
|
"service/library/mediafiller"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func OpCreateMoment(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpCreateReq)
|
|
|
|
ec := service.DefaultService.OpCreateMoment(ctx, req)
|
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
2024-01-13 00:32:19 +08:00
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
2023-12-21 22:17:40 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ReplyOk(ctx, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func OpUpdateMoment(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpUpdateReq)
|
|
|
|
ec := service.DefaultService.OpUpdateMoment(ctx, req)
|
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpUpdateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ReplyOk(ctx, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func OpDeleteMoment(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpDeleteReq)
|
2024-01-27 02:04:17 +08:00
|
|
|
ec := service.DefaultService.OpDeleteMoment(ctx, req)
|
2023-12-21 22:17:40 +08:00
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpDeleteMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ReplyOk(ctx, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func OpGetMomentList(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpListReq)
|
|
|
|
|
|
|
|
//设置默认页长
|
|
|
|
if req.Limit == 0 {
|
|
|
|
req.Limit = consts.DefaultPageSize
|
|
|
|
}
|
|
|
|
|
|
|
|
list, ec := service.DefaultService.OpGetMomentList(ctx, req)
|
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpGetMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
//填充媒体切片
|
|
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list))
|
2024-03-27 20:29:22 +08:00
|
|
|
for i, media := range list {
|
|
|
|
mediaFillableList[i] = media.MediaComp
|
|
|
|
}
|
|
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
|
|
|
|
data := &momentproto.OpListData{
|
|
|
|
List: list,
|
|
|
|
Offset: req.Offset + len(list),
|
|
|
|
}
|
|
|
|
if len(list) >= req.Limit {
|
|
|
|
data.More = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
ReplyOk(ctx, data)
|
|
|
|
}
|
|
|
|
|
|
|
|
func OpGetDeletedMomentList(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpListReq)
|
|
|
|
|
|
|
|
//设置默认页长
|
|
|
|
if req.Limit == 0 {
|
|
|
|
req.Limit = consts.DefaultPageSize
|
|
|
|
}
|
|
|
|
|
|
|
|
list, ec := service.DefaultService.OpGetDeletedMomentList(ctx, req)
|
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpGetMomentList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
//填充媒体切片
|
|
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list))
|
2023-12-21 22:17:40 +08:00
|
|
|
for i, media := range list {
|
|
|
|
mediaFillableList[i] = media.MediaComp
|
|
|
|
}
|
|
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
|
|
|
|
data := &momentproto.OpListData{
|
|
|
|
List: list,
|
|
|
|
Offset: req.Offset + len(list),
|
|
|
|
}
|
|
|
|
if len(list) >= req.Limit {
|
|
|
|
data.More = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
ReplyOk(ctx, data)
|
|
|
|
}
|
|
|
|
|
2024-02-05 18:47:51 +08:00
|
|
|
func OpGetMomentListByMid(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpListByMidReq)
|
|
|
|
|
|
|
|
//设置默认页长
|
|
|
|
if req.Limit == 0 {
|
|
|
|
req.Limit = consts.DefaultPageSize
|
|
|
|
}
|
|
|
|
|
|
|
|
list, ec := service.DefaultService.OpGetMomentListByMid(ctx, req)
|
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpGetMomentListByMid fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
//填充媒体切片
|
|
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list))
|
|
|
|
for i, media := range list {
|
|
|
|
mediaFillableList[i] = media.MediaComp
|
|
|
|
}
|
|
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
|
|
|
|
data := &momentproto.OpListData{
|
|
|
|
List: list,
|
|
|
|
Offset: req.Offset + len(list),
|
|
|
|
}
|
|
|
|
if len(list) >= req.Limit {
|
|
|
|
data.More = 1
|
|
|
|
}
|
|
|
|
|
2024-02-05 19:09:18 +08:00
|
|
|
ReplyOk(ctx, data)
|
|
|
|
|
2024-02-05 18:47:51 +08:00
|
|
|
}
|
|
|
|
|
2024-02-01 10:19:44 +08:00
|
|
|
func OpGetMomentListByIds(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpListByIdsReq)
|
|
|
|
|
|
|
|
list, ec := service.DefaultService.OpGetMomentListByIds(ctx, req)
|
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpGetMomentListByIds fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
//填充媒体切片
|
|
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list))
|
|
|
|
for i, media := range list {
|
|
|
|
mediaFillableList[i] = media.MediaComp
|
|
|
|
}
|
|
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
|
|
|
|
data := &momentproto.OpListData{
|
|
|
|
List: list,
|
|
|
|
}
|
|
|
|
|
|
|
|
ReplyOk(ctx, data)
|
|
|
|
}
|
|
|
|
|
2023-12-21 22:17:40 +08:00
|
|
|
func OpThumbsUpMoment(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpThumbsUpReq)
|
2024-01-13 00:32:19 +08:00
|
|
|
ec := service.DefaultService.OpThumbsUpMoment(ctx, req)
|
2023-12-21 22:17:40 +08:00
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpThumbsUpMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-13 00:32:19 +08:00
|
|
|
ReplyOk(ctx, nil)
|
2023-12-21 22:17:40 +08:00
|
|
|
}
|
2024-03-29 00:16:42 +08:00
|
|
|
|
|
|
|
func OpReviewMoment(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*momentproto.OpReviewReq)
|
|
|
|
ec := service.DefaultService.OpReviewMoment(ctx, req)
|
|
|
|
if ec != errcode.ErrCodeMomentSrvOk {
|
|
|
|
logger.Error("OpReviewMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ReplyOk(ctx, nil)
|
|
|
|
}
|