feat-IRONFANS-53-20240205-Robin #102

Merged
chenhao merged 3 commits from feat-IRONFANS-53-20240205-Robin into test 2024-02-05 21:21:14 +08:00
4 changed files with 84 additions and 0 deletions
Showing only changes of commit ed1eb7b461 - Show all commits

View File

@ -263,6 +263,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)
opMomentGroup.POST("list_by_ids", middleware.JSONParamValidator(momentproto.OpListByIdsReq{}), middleware.JwtAuthenticator(), OpGetMomentListByIds)

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 OpGetMomentListByIds(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*momentproto.OpListByIdsReq)

View File

@ -1200,6 +1200,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) OpGetMomentListByIdsBusinessValidate(ctx *gin.Context, req *momentproto.OpListByIdsReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk
// 1.业务校验

View File

@ -1079,6 +1079,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) OpGetMomentListByIds(ctx *gin.Context, req *momentproto.OpListByIdsReq) (voList []*momentproto.OpMomentVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk