Merge pull request 'feat-IRONFANS-70' (#351) from feat-IRONFANS-70 into test
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/351
This commit is contained in:
commit
629555ad36
|
@ -50,6 +50,7 @@ const (
|
|||
MaxDailyMomentCreateTimesKey = "max_daily_moment_create_times"
|
||||
DefaultMomentTextKey = "default_moment_text"
|
||||
MaxDailyZoneMomentCreateTimesKey = "max_daily_zone_moment_create_times"
|
||||
ZoneKey = "zone"
|
||||
)
|
||||
|
||||
// del_flag
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package apollostruct
|
||||
|
||||
import "service/dbstruct"
|
||||
|
||||
type ReferentialZoneMoment struct {
|
||||
Text *string `json:"text"` // 动态文字内容
|
||||
MediaComp *dbstruct.MediaComponent `json:"media_component"` // 动态媒体内容
|
||||
MType *int64 `json:"m_type"` // 媒体类型,见: MediaType*
|
||||
Status *int64 `json:"status"` // 审批状态
|
||||
}
|
|
@ -4712,16 +4712,13 @@ func (m *Mongo) GetZoneMomentCreateTimes(ctx *gin.Context, mid int64) (momentCre
|
|||
return momentCreateTimes, err
|
||||
}
|
||||
|
||||
func (m *Mongo) GetAndUpdateZoneMomentCreateTimes(ctx *gin.Context, mid int64, cType int64) (momentCreateTimes *dbstruct.ZoneMomentCreateTimes, err error) {
|
||||
func (m *Mongo) GetAndUpdateZoneMomentCreateTimes(ctx *gin.Context, mid, totalIncr, freeIncr, paidIncr int64) (momentCreateTimes *dbstruct.ZoneMomentCreateTimes, err error) {
|
||||
col := m.getColZoneMomentCreateTimes()
|
||||
|
||||
incClause := qmgo.M{
|
||||
"create_times": 1,
|
||||
}
|
||||
if cType == consts.ZoneMomentCType_Free {
|
||||
incClause["free_create_times"] = 1
|
||||
} else if cType == consts.ZoneMomentCType_Paid {
|
||||
incClause["paid_create_times"] = 1
|
||||
"create_times": totalIncr,
|
||||
"free_create_times": freeIncr,
|
||||
"paid_create_times": paidIncr,
|
||||
}
|
||||
|
||||
change := qmgo.Change{
|
||||
|
|
|
@ -2154,6 +2154,31 @@ func (s *Service) ApiCreateZone(ctx *gin.Context, req *zoneproto.ApiCreateReq) (
|
|||
return
|
||||
}
|
||||
|
||||
// 创建默认动态
|
||||
cfg := apollostruct.ReferentialZoneMoment{}
|
||||
err = apollo.GetJson(consts.ZoneKey, &cfg, apollo.ApolloOpts().SetNamespace("referential_zone_moment"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
return errcode.ErrCodeApolloReadFail
|
||||
}
|
||||
|
||||
_, err = _DefaultZoneMoment.OpCreate(ctx, &zonemomentproto.OpCreateReq{
|
||||
ZoneMoment: &dbstruct.ZoneMoment{
|
||||
Mid: req.Zone.Mid,
|
||||
Zid: goproto.Int64(zid),
|
||||
CType: goproto.Int64(consts.ZoneMomentCType_Free),
|
||||
Text: cfg.Text,
|
||||
MediaComp: cfg.MediaComp,
|
||||
MType: cfg.MType,
|
||||
Status: cfg.Status,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("_DefaultZoneMoment OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2620,6 +2645,16 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api
|
|||
}
|
||||
}
|
||||
|
||||
// 回退每日发帖次数
|
||||
totalIncr, freeIncr, paidIncr := int64(-1), int64(0), int64(0)
|
||||
if zonemoment.GetCType() == consts.ZoneMomentCType_Free {
|
||||
freeIncr = -1
|
||||
} else if zonemoment.GetCType() == consts.ZoneMomentCType_Paid {
|
||||
paidIncr = -1
|
||||
}
|
||||
_, err = _DefaultZoneMomentCreateTimes.OpGetAndUpdate(ctx, zone.GetMid(), totalIncr, freeIncr, paidIncr)
|
||||
logger.Error("OpGetAndUpdate fail, err: %v", err)
|
||||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ func (l *AuthBusinessValidator) EnsureSuchAccountPunishmentNotExist(uid int64, t
|
|||
return l
|
||||
}
|
||||
|
||||
func (l *AuthBusinessValidator) EnsureZoneMomentCreateTimesNotReachedDailyUpperbound(fun func(*gin.Context, int64, int64) (*dbstruct.ZoneMomentCreateTimes, error), mid int64, cType int64) *AuthBusinessValidator {
|
||||
func (l *AuthBusinessValidator) EnsureZoneMomentCreateTimesNotReachedDailyUpperbound(fun func(*gin.Context, int64, int64, int64, int64) (*dbstruct.ZoneMomentCreateTimes, error), mid int64, cType int64) *AuthBusinessValidator {
|
||||
l.oplist = append(l.oplist, func() {
|
||||
|
||||
// 读取每日发送上限
|
||||
|
@ -471,7 +471,14 @@ func (l *AuthBusinessValidator) EnsureZoneMomentCreateTimesNotReachedDailyUpperb
|
|||
return
|
||||
}
|
||||
|
||||
zoneMomentCreateTimes, err := fun(l.ctx, mid, cType)
|
||||
totalIncr, freeIncr, paidIncr := int64(1), int64(0), int64(0)
|
||||
if cType == consts.ZoneMomentCType_Free {
|
||||
freeIncr = 1
|
||||
} else if cType == consts.ZoneMomentCType_Paid {
|
||||
paidIncr = 1
|
||||
}
|
||||
|
||||
zoneMomentCreateTimes, err := fun(l.ctx, mid, totalIncr, freeIncr, paidIncr)
|
||||
if err != nil {
|
||||
l.ec = errcode.ErrCodeZoneMomentCreateTimesSrvFail
|
||||
return
|
||||
|
|
|
@ -30,9 +30,9 @@ func (p *ZoneMomentCreateTimes) OpGetOne(ctx *gin.Context, mid int64) (*dbstruct
|
|||
return zoneMomentCreateTimes, nil
|
||||
}
|
||||
|
||||
func (p *ZoneMomentCreateTimes) OpGetAndUpdate(ctx *gin.Context, mid int64, cType int64) (*dbstruct.ZoneMomentCreateTimes, error) {
|
||||
func (p *ZoneMomentCreateTimes) OpGetAndUpdate(ctx *gin.Context, mid, totalIncr, freeIncr, paidIncr int64) (*dbstruct.ZoneMomentCreateTimes, error) {
|
||||
|
||||
zoneMomentCreateTimes, err := p.store.GetAndUpdateZoneMomentCreateTimes(ctx, mid, cType)
|
||||
zoneMomentCreateTimes, err := p.store.GetAndUpdateZoneMomentCreateTimes(ctx, mid, totalIncr, freeIncr, paidIncr)
|
||||
if err != nil {
|
||||
logger.Error("GetAndUpdateZoneMomentCreateTimes fail, err: %v", err)
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue