by Robin at 20240327; op list deleted

This commit is contained in:
Leufolium 2024-03-27 20:29:22 +08:00
parent 4aff0176cc
commit fd1706dd51
5 changed files with 97 additions and 0 deletions

View File

@ -278,6 +278,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_deleted", middleware.JSONParamValidator(momentproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetDeletedMomentList)
opMomentGroup.POST("list_by_mid", middleware.JSONParamValidator(momentproto.OpListByMidReq{}), 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,39 @@ func OpGetMomentList(ctx *gin.Context) {
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))
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 OpGetMomentListByMid(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*momentproto.OpListByMidReq)

View File

@ -1385,6 +1385,31 @@ func (m *Mongo) GetMomentList(ctx *gin.Context, req *momentproto.OpListReq) ([]*
return list, err
}
// 临时接口
func (m *Mongo) GetDeletedMomentList(ctx *gin.Context, req *momentproto.OpListReq) ([]*dbstruct.Moment, error) {
list := make([]*dbstruct.Moment, 0)
col := m.getColMoment()
//ct_lower_bound < ct <= ct_upper_bound
ctClause := qmgo.M{}
if req.CtLowerBound != nil {
ctClause["$gt"] = util.DerefInt64(req.CtLowerBound)
}
if req.CtUpperBound != nil {
ctClause["$lte"] = util.DerefInt64(req.CtUpperBound)
}
query := qmgo.M{
"ct": ctClause,
"status": 3,
"del_flag": 0,
}
err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments {
err = nil
return list, err
}
return list, err
}
func (m *Mongo) GetMomentListByIds(ctx *gin.Context, req *momentproto.OpListByIdsReq) ([]*dbstruct.Moment, error) {
list := make([]*dbstruct.Moment, 0)
col := m.getColMoment()

View File

@ -73,6 +73,15 @@ func (p *Moment) OpList(ctx *gin.Context, req *momentproto.OpListReq) ([]*dbstru
return list, nil
}
func (p *Moment) OpListDeleted(ctx *gin.Context, req *momentproto.OpListReq) ([]*dbstruct.Moment, error) {
list, err := p.store.GetDeletedMomentList(ctx, req)
if err != nil {
logger.Error("GetDeletedMMomentList fail, err: %v", err)
return make([]*dbstruct.Moment, 0), err
}
return list, nil
}
func (p *Moment) OpListByIds(ctx *gin.Context, req *momentproto.OpListByIdsReq) ([]*dbstruct.Moment, error) {
list, err := p.store.GetMomentListByIds(ctx, req)
if err != nil {

View File

@ -1214,6 +1214,35 @@ func (s *Service) OpGetMomentList(ctx *gin.Context, req *momentproto.OpListReq)
return
}
func (s *Service) OpGetDeletedMomentList(ctx *gin.Context, req *momentproto.OpListReq) (voList []*momentproto.OpMomentVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk
if ec = s.OpGetMomentListBusinessValidate(ctx, req); ec != errcode.ErrCodeMomentSrvOk {
return
}
list, err := _DefaultMoment.OpListDeleted(ctx, req)
if err != nil {
logger.Error("OpGetDeletedMomentList 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 {
opVO, _ := vo.(*momentproto.OpMomentVO)
voList = append(voList, opVO)
}
return
}
func (s *Service) OpGetMomentListByMid(ctx *gin.Context, req *momentproto.OpListByMidReq) (voList []*momentproto.OpMomentVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk