Merge pull request 'feat-IRONFANS-70' (#250) from feat-IRONFANS-70 into test
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/250
This commit is contained in:
commit
711aaa3d03
|
@ -208,3 +208,9 @@ const (
|
|||
IsUnreadZoneMomentExist_No = 0 //否
|
||||
IsUnreadZoneMomentExist_Yes = 1 //是
|
||||
)
|
||||
|
||||
// 是否置顶
|
||||
const (
|
||||
IsHeaded_No = 0 //否
|
||||
IsHeaded_Yes = 1 //是
|
||||
)
|
||||
|
|
|
@ -80,3 +80,11 @@ func (p *ApiListByZidReq) ProvideNotNullValue() (params []*validator.JsonParam)
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
func (p *ApiHeadReq) ProvideNotNullValue() (params []*validator.JsonParam) {
|
||||
params = make([]*validator.JsonParam, 0)
|
||||
|
||||
params = append(params, validator.NewInt64SliceParam("请确认待审批动态的ids!", p.ZoneMomentIds))
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -131,3 +131,18 @@ type ApiZoneMomentThumbsUpResp struct {
|
|||
base.BaseResponse
|
||||
Data *ApiZoneMomentThumbsUpData `json:"data"`
|
||||
}
|
||||
|
||||
// op 置顶
|
||||
type ApiHeadReq struct {
|
||||
base.BaseRequest
|
||||
ZoneMomentIds []int64 `json:"zone_moment_ids"`
|
||||
OpType int64 `json:"op_type"`
|
||||
}
|
||||
|
||||
type ApiHeadData struct {
|
||||
}
|
||||
|
||||
type ApiHeadResp struct {
|
||||
base.BaseResponse
|
||||
Data *ApiHeadData `json:"data"`
|
||||
}
|
||||
|
|
|
@ -247,6 +247,7 @@ func Init(r *gin.Engine) {
|
|||
apiZoneMomentGroup.POST("list_by_creater_mid", middleware.JSONParamValidator(zonemomentproto.ApiListByCreaterMidReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentListByCreaterMid)
|
||||
apiZoneMomentGroup.POST("list_by_zid", middleware.JSONParamValidator(zonemomentproto.ApiListByZidReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentListByZid)
|
||||
apiZoneMomentGroup.POST("thumbs_up", middleware.JSONParamValidator(zonemomentproto.ApiZoneMomentThumbsUpReq{}), middleware.JwtAuthenticator(), ApiZoneMomentThumbsUpMoment)
|
||||
apiZoneMomentGroup.POST("head", middleware.JSONParamValidator(zonemomentproto.ApiHeadReq{}), middleware.JwtAuthenticator(), ApiHeadZoneMoment)
|
||||
|
||||
// 空间对话
|
||||
apiZoneSessionGroup := r.Group("/api/zone_session", PrepareToC())
|
||||
|
|
|
@ -172,3 +172,15 @@ func ApiZoneMomentThumbsUpMoment(ctx *gin.Context) {
|
|||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
||||
func ApiHeadZoneMoment(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zonemomentproto.ApiHeadReq)
|
||||
ec := service.DefaultService.ApiHeadZoneMoment(ctx, req)
|
||||
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
||||
logger.Error("ApiHeadZoneMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
|
|
@ -3947,6 +3947,7 @@ func (m *Mongo) GetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.Op
|
|||
if req.Status != nil {
|
||||
query["status"] = util.DerefInt64(req.Status)
|
||||
}
|
||||
|
||||
ctClause := qmgo.M{}
|
||||
if req.CtLowerBound != nil {
|
||||
ctClause["$gt"] = util.DerefInt64(req.CtLowerBound)
|
||||
|
@ -3954,9 +3955,16 @@ func (m *Mongo) GetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.Op
|
|||
if req.CtUpperBound != nil {
|
||||
ctClause["$lte"] = util.DerefInt64(req.CtUpperBound)
|
||||
}
|
||||
if len(ctClause) != 0 {
|
||||
query["ct"] = ctClause
|
||||
}
|
||||
|
||||
orClause := make([]qmgo.M, 0)
|
||||
orClause = append(orClause, qmgo.M{
|
||||
"is_headed": consts.IsHeaded_Yes,
|
||||
})
|
||||
orClause = append(orClause, qmgo.M{
|
||||
"priority_in_zone": ctClause,
|
||||
})
|
||||
|
||||
query["$or"] = orClause
|
||||
err := col.Find(ctx, query).Sort("-priority_in_zone").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
err = nil
|
||||
|
@ -4104,6 +4112,15 @@ func (m *Mongo) IncZoneMomentPriorityByIds(ctx *gin.Context, ids []int64, increm
|
|||
"priority_in_zone": increment,
|
||||
},
|
||||
}
|
||||
if increment == consts.ZoneMomentPriorityInZone_Increment {
|
||||
up["$set"] = qmgo.M{
|
||||
"is_headed": consts.IsHeaded_Yes,
|
||||
}
|
||||
} else {
|
||||
up["$set"] = qmgo.M{
|
||||
"is_headed": consts.IsHeaded_No,
|
||||
}
|
||||
}
|
||||
_, err := col.UpdateAll(ctx, query, up)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -2634,6 +2634,27 @@ func (s *Service) ApiGetZoneMomentListByCreaterMid(ctx *gin.Context, req *zonemo
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiHeadZoneMoment(ctx *gin.Context, req *zonemomentproto.ApiHeadReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneMomentSrvOk
|
||||
|
||||
incr := int64(0)
|
||||
if req.OpType == consts.ZoneMomentHead_Head {
|
||||
incr = consts.ZoneMomentPriorityInZone_Increment
|
||||
} else {
|
||||
incr = consts.ZoneMomentPriorityInZone_Decrement
|
||||
}
|
||||
|
||||
// 更新动态的状态
|
||||
err := _DefaultZoneMoment.OpIncPriorityByIds(ctx, req.ZoneMomentIds, incr)
|
||||
if err != nil {
|
||||
logger.Error("_DefaultZoneMoment OpIncPriorityByIds fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiZoneMomentThumbsUpMoment(ctx *gin.Context, req *zonemomentproto.ApiZoneMomentThumbsUpReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneMomentSrvOk
|
||||
|
||||
|
|
|
@ -36,7 +36,8 @@ func (p *ZoneMoment) OpCreate(ctx *gin.Context, req *zonemomentproto.OpCreateReq
|
|||
req.ZoneMoment.Ct = goproto.Int64(time.Now().Unix())
|
||||
req.ZoneMoment.Ut = goproto.Int64(time.Now().Unix())
|
||||
req.ZoneMoment.DelFlag = goproto.Int64(consts.Exist)
|
||||
req.ZoneMoment.PriorityInZone = req.ZoneMoment.Ct // 优先级默认按创建时间
|
||||
req.ZoneMoment.PriorityInZone = req.ZoneMoment.Ct // 优先级默认按创建时间
|
||||
req.ZoneMoment.IsHeaded = goproto.Int64(consts.IsHeaded_No) // 未置顶
|
||||
err = p.store.CreateZoneMoment(ctx, req.ZoneMoment)
|
||||
if err != nil {
|
||||
logger.Error("CreateZoneMoment fail, err: %v", err)
|
||||
|
|
|
@ -28,6 +28,7 @@ type ZoneMoment struct {
|
|||
ManuallyReviewOpinion *string `json:"manually_review_opinion" bson:"manually_review_opinion"` // 人工复审意见
|
||||
ManuallyReviewOperator *int64 `json:"manually_review_operator" bson:"manually_review_operator"` // 人工复审操作人
|
||||
PriorityInZone *int64 `json:"priority_in_zone" bson:"priority_in_zone"` // 优先级
|
||||
IsHeaded *int64 `json:"is_headed" bson:"is_headed"` // 是否已置顶
|
||||
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
||||
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
||||
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记
|
||||
|
|
Loading…
Reference in New Issue