by Robin at 20240501

This commit is contained in:
Leufolium 2024-05-01 02:51:47 +08:00
parent aca9281087
commit d494eb921b
7 changed files with 84 additions and 2 deletions

View File

@ -179,6 +179,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodeZoneMomentNotExist: "私密圈动态不存在",
ErrCodePaidZoneMomentCreateTimesReachedUpperbound: "付费动态不能多于免费动态",
ErrCodeZoneMomentImagesNotEnoughForEncryption: "预览图片数不得大于等于上传图片数",
ErrCodeZoneMomentStatusNotPublic: "私密圈动态状态不为公开!",
ErrCodeZoneMomentThumbsUpSrvFail: "私密圈点赞服务错误",
ErrCodeZoneMomentThumbsUpNotExist: "私密圈点赞不存在",
@ -455,6 +456,7 @@ const (
ErrCodeZoneMomentNotExist ErrCode = -34002 // 私密圈动态不存在
ErrCodePaidZoneMomentCreateTimesReachedUpperbound ErrCode = -34003 // 私密圈付费动态创建次数已达上限
ErrCodeZoneMomentImagesNotEnoughForEncryption ErrCode = -34004 // 私密圈图片贴图片数量少于可预览图片数
ErrCodeZoneMomentStatusNotPublic ErrCode = -34005 // 私密圈动态非公开状态
// ZoneMomentThumbsUp: 35xxx
ErrCodeZoneMomentThumbsUpSrvOk ErrCode = ErrCodeOk

View File

@ -75,3 +75,11 @@ func (p *OpHeadReq) ProvideNotNullValue() (params []*validator.JsonParam) {
return
}
func (p *OpSetPrivateReq) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewInt64PtrParam("请确认待审批动态的id", p.ZoneMomentId))
return
}

View File

@ -209,3 +209,17 @@ type OpHeadResp struct {
base.BaseResponse
Data *OpHeadData `json:"data"`
}
// op 退回动态
type OpSetPrivateReq struct {
base.BaseRequest
ZoneMomentId *int64 `json:"zone_moment_id"`
}
type OpSetPrivateData struct {
}
type OpSetPrivateResp struct {
base.BaseResponse
Data *OpSetPrivateData `json:"data"`
}

View File

@ -509,6 +509,7 @@ func Init(r *gin.Engine) {
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)
opZoneMomentGroup.POST("set_private", middleware.JSONParamValidator(zonemomentproto.OpSetPrivateReq{}), middleware.JwtAuthenticator(), OpSetPrivateZoneMoment)
// 视频审核callback
extVideoModerationGroup := r.Group("/ext/video_moderation")

View File

@ -135,3 +135,15 @@ func OpHeadZoneMoment(ctx *gin.Context) {
ReplyOk(ctx, nil)
}
func OpSetPrivateZoneMoment(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*zonemomentproto.OpSetPrivateReq)
ec := service.DefaultService.OpSetPrivateZoneMoment(ctx, req)
if ec != errcode.ErrCodeZoneMomentSrvOk {
logger.Error("OpSetPrivateZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}

View File

@ -75,7 +75,7 @@ func (p *ZoneMoment) OpList(ctx *gin.Context, req *zonemomentproto.OpListReq) ([
func (p *ZoneMoment) GetById(ctx *gin.Context, id int64) (*dbstruct.ZoneMoment, error) {
zonemoment, err := p.store.GetZoneMomentById(ctx, id)
if err != nil {
logger.Error("GetZoneMomentList fail, err: %v", err)
logger.Error("GetZoneMomentById fail, err: %v", err)
return &dbstruct.ZoneMoment{}, err
}
return zonemoment, nil

View File

@ -3601,7 +3601,7 @@ func (s *Service) OpHeadZoneMoment(ctx *gin.Context, req *zonemomentproto.OpHead
// 更新动态的状态
err := _DefaultZoneMoment.OpHeadByIds(ctx, req.ZoneMomentIds, req.OpType)
if err != nil {
logger.Error("_DefaultZoneMoment OpIncPriorityByIds fail, req: %v, err: %v", util.ToJson(req), err)
logger.Error("_DefaultZoneMoment OpHeadByIds fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
}
@ -3609,6 +3609,51 @@ func (s *Service) OpHeadZoneMoment(ctx *gin.Context, req *zonemomentproto.OpHead
return
}
func (s *Service) OpSetPrivateZoneMoment(ctx *gin.Context, req *zonemomentproto.OpSetPrivateReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneMomentSrvOk
// 保证动态的状态都是公开的
zonemoment, err := _DefaultZoneMoment.GetById(ctx, util.DerefInt64(req.ZoneMomentId))
if err != nil {
logger.Error("_DefaultZoneMoment GetById fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
}
if zonemoment == nil {
ec = errcode.ErrCodeZoneMomentNotExist
return
}
if zonemoment.GetStatus() != consts.ZoneMoment_Public {
ec = errcode.ErrCodeZoneMomentStatusNotPublic
return
}
// 更新动态的状态
err = _DefaultZoneMoment.OpUpdate(ctx, &zonemomentproto.OpUpdateReq{
ZoneMoment: &dbstruct.ZoneMoment{
Id: req.ZoneMomentId,
Status: goproto.Int64(consts.ZoneMoment_Private),
},
})
if err != nil {
logger.Error("_DefaultZoneMoment OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
}
// 回退空间内统计总数
mediaCountInc := len(zonemoment.MediaComp.GetImageIds())
videoCountInc := len(zonemoment.MediaComp.GetVideoIds())
err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc))
if err != nil {
logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
}
return
}
// ZoneThirdPartner
func (s *Service) OpCreateZoneThirdPartner(ctx *gin.Context, req *zone_third_partner_proto.OpCreateReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneThirdPartnerSrvOk