From 4137710945611cf319eff28e7bccc31aa0875723 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Fri, 26 Apr 2024 11:13:49 +0800 Subject: [PATCH] by Robin at 20240426 --- api/consts/consts.go | 1 + apollostruct/referential_zone_moment.go | 10 +++++++++ app/mix/service/apiservice.go | 27 +++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 apollostruct/referential_zone_moment.go diff --git a/api/consts/consts.go b/api/consts/consts.go index fdfb0f99..0ff7b398 100644 --- a/api/consts/consts.go +++ b/api/consts/consts.go @@ -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 diff --git a/apollostruct/referential_zone_moment.go b/apollostruct/referential_zone_moment.go new file mode 100644 index 00000000..f0e57e86 --- /dev/null +++ b/apollostruct/referential_zone_moment.go @@ -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"` // 审批状态 +} diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 5c432795..66116068 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2147,6 +2147,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 } @@ -2629,8 +2654,6 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api logger.Error("OpGetAndUpdate fail, err: %v", err) ec = errcode.ErrCodeZoneMomentSrvFail return - - return } func (s *Service) ApiGetZoneMomentListByVisitorMid(ctx *gin.Context, req *zonemomentproto.ApiListByVisitorMidReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) {