by Robin at 20240205; add op moment list by mid

This commit is contained in:
Leufolium 2024-02-05 18:47:51 +08:00
parent e8eabcc42e
commit 9e85281c9f
4 changed files with 84 additions and 0 deletions

View File

@ -255,6 +255,7 @@ func Init(r *gin.Engine) {
opMomentGroup.POST("update", middleware.JSONParamValidator(momentproto.OpUpdateReq{}), middleware.JwtAuthenticator(), OpUpdateMoment)
opMomentGroup.POST("delete", middleware.JSONParamValidator(momentproto.OpDeleteReq{}), middleware.JwtAuthenticator(), OpDeleteMoment)
opMomentGroup.POST("list", middleware.JSONParamValidator(momentproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetMomentList)
opMomentGroup.POST("list_by_mid", middleware.JSONParamValidator(momentproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetMomentListByMid)
opMomentGroup.POST("thumbs_up", middleware.JSONParamValidator(momentproto.OpThumbsUpReq{}), middleware.JwtAuthenticator(), OpThumbsUpMoment)
// 足迹

View File

@ -81,6 +81,38 @@ func OpGetMomentList(ctx *gin.Context) {
ReplyOk(ctx, data)
}
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
}
}
func OpThumbsUpMoment(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*momentproto.OpThumbsUpReq)
ec := service.DefaultService.OpThumbsUpMoment(ctx, req)

View File

@ -1199,6 +1199,22 @@ func (s *Service) OpGetMomentListBusinessValidate(ctx *gin.Context, req *momentp
return
}
func (s *Service) OpGetMomentListByMidBusinessValidate(ctx *gin.Context, req *momentproto.OpListByMidReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk
// 1.业务校验
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
QueryAccount(_DefaultAccount.OpListByMid).
EnsureAccountExist().
EnsureIsOpRole().
Validate().
Collect()
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
logger.Error("OpGetMomentListByMid business validation failed")
return
}
return
}
func (s *Service) OpThumbsUpMomentBusinessValidate(ctx *gin.Context, req *momentproto.OpThumbsUpReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk
// 1.业务校验

View File

@ -1057,6 +1057,41 @@ func (s *Service) OpGetMomentList(ctx *gin.Context, req *momentproto.OpListReq)
return
}
func (s *Service) OpGetMomentListByMid(ctx *gin.Context, req *momentproto.OpListByMidReq) (voList []*momentproto.OpMomentVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk
if ec = s.OpGetMomentListByMidBusinessValidate(ctx, req); ec != errcode.ErrCodeMomentSrvOk {
return
}
list, err := _DefaultMoment.OpListByMid(ctx, &momentproto.OpListByMidReq{
Mid: req.Mid,
CtUpperBound: req.CtUpperBound,
CtLowerBound: req.CtLowerBound,
Offset: req.Offset,
Limit: req.Limit,
})
if err != nil {
logger.Error("OpGetMomentListByMid fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeMomentSrvFail
return
}
// 填充主播信息
vos, ec := s.utilFillMomentsStreamerInfo(ctx, list, consts.InterfaceType_Op)
if ec != errcode.ErrCodeMomentSrvOk {
logger.Error("utilFillMomentsStreamerInfo fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeMomentSrvFail
return
}
voList = make([]*momentproto.OpMomentVO, 0)
for _, vo := range vos {
apiVO, _ := vo.(*momentproto.OpMomentVO)
voList = append(voList, apiVO)
}
return
}
func (s *Service) OpThumbsUpMoment(ctx *gin.Context, req *momentproto.OpThumbsUpReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk