diff --git a/api/proto/zonemoment/proto/zonemoment_op.go b/api/proto/zonemoment/proto/zonemoment_op.go index af80eb9e..e07eb587 100644 --- a/api/proto/zonemoment/proto/zonemoment_op.go +++ b/api/proto/zonemoment/proto/zonemoment_op.go @@ -140,6 +140,27 @@ type OpListByZidResp struct { Data *OpListByZidData `json:"data"` } +// op 列表-user_id直查 +type OpListByUserIdReq struct { + base.BaseRequest + UserId int64 `json:"user_id"` //user_id + CtUpperBound *int64 `json:"ct_upper_bound"` //创建时间上界,闭区间 + CtLowerBound *int64 `json:"ct_lower_bound"` //创建时间下界,开区间,可为0 + Offset int `json:"offset"` + Limit int `json:"limit"` +} + +type OpListByUserIdData struct { + ListByUserId []*OpZoneMomentVO `json:"list"` + Offset int `json:"offset"` + More int `json:"more"` +} + +type OpListByUserIdResp struct { + base.BaseResponse + Data *OpListByUserIdData `json:"data"` +} + // op 点赞 type OpZoneMomentThumbsUpReq struct { base.BaseRequest diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index c8d5d294..2f8d2271 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -500,6 +500,7 @@ func Init(r *gin.Engine) { opZoneMomentGroup.POST("update", middleware.JSONParamValidator(zonemomentproto.OpUpdateReq{}), middleware.JwtAuthenticator(), OpUpdateZoneMoment) opZoneMomentGroup.POST("delete", middleware.JSONParamValidator(zonemomentproto.OpDeleteReq{}), middleware.JwtAuthenticator(), OpDeleteZoneMoment) opZoneMomentGroup.POST("list", middleware.JSONParamValidator(zonemomentproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetZoneMomentList) + opZoneMomentGroup.POST("list_by_user_id", middleware.JSONParamValidator(zonemomentproto.OpListByUserIdReq{}), middleware.JwtAuthenticator(), OpGetZoneMomentListByUserId) opZoneMomentGroup.POST("review", middleware.JSONParamValidator(zonemomentproto.OpReviewReq{}), middleware.JwtAuthenticator(), OpReviewZoneMoment) opZoneMomentGroup.POST("head", middleware.JSONParamValidator(zonemomentproto.OpHeadReq{}), middleware.JwtAuthenticator(), OpHeadZoneMoment) diff --git a/app/mix/controller/zonemoment_op.go b/app/mix/controller/zonemoment_op.go index 5306aecc..165e3aa6 100644 --- a/app/mix/controller/zonemoment_op.go +++ b/app/mix/controller/zonemoment_op.go @@ -80,6 +80,38 @@ func OpGetZoneMomentList(ctx *gin.Context) { ReplyOk(ctx, data) } +func OpGetZoneMomentListByUserId(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*zonemomentproto.OpListByUserIdReq) + + //设置默认页长 + if req.Limit == 0 { + req.Limit = consts.DefaultPageSize + } + + list, ec := service.DefaultService.OpGetZoneMomentListByUserId(ctx, req) + if ec != errcode.ErrCodeZoneMomentSrvOk { + logger.Error("OpGetZoneMomentListByUserId 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 := &zonemomentproto.OpListByUserIdData{ + ListByUserId: list, + Offset: req.Offset + len(list), + } + if len(list) >= req.Limit { + data.More = 1 + } + ReplyOk(ctx, data) +} + func OpReviewZoneMoment(ctx *gin.Context) { req := ctx.MustGet("client_req").(*zonemomentproto.OpReviewReq) ec := service.DefaultService.OpReviewZoneMoment(ctx, req) diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 6201517a..d77aab89 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3368,6 +3368,42 @@ func (s *Service) OpGetZoneMomentList(ctx *gin.Context, req *zonemomentproto.OpL return } +func (s *Service) OpGetZoneMomentListByUserId(ctx *gin.Context, req *zonemomentproto.OpListByUserIdReq) (volist []*zonemomentproto.OpZoneMomentVO, ec errcode.ErrCode) { + ec = errcode.ErrCodeZoneMomentSrvOk + + account, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{ + UserId: goproto.Int64(req.UserId), + }) + if err != nil { + logger.Error("_DefaultAccount OpListByUserId fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } + if account == nil { + return + } + + list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ + BaseRequest: req.BaseRequest, + CtUpperBound: req.CtUpperBound, + CtLowerBound: req.CtLowerBound, + }) + if err != nil { + logger.Error("OpGetZoneMomentListByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneMomentSrvFail + return + } + + // 填充信息 + volist, err = s.utilFillZoneMomentsWithOpVOInfo(ctx, list) + if err != nil { + logger.Error("utilFillZoneMomentsWithOpVOInfo fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneMomentSrvFail + return + } + return +} + func (s *Service) OpReviewZoneMoment(ctx *gin.Context, req *zonemomentproto.OpReviewReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeZoneMomentSrvOk