From aa32674ed337de80d9897bd9384b843e61d368ca Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 30 Apr 2024 09:40:19 +0800 Subject: [PATCH 1/2] by Robin at 20240430 --- api/proto/zonemoment/proto/zonemoment_op.go | 5 +++-- app/mix/dao/mongo.go | 6 ++++++ app/mix/service/service.go | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/proto/zonemoment/proto/zonemoment_op.go b/api/proto/zonemoment/proto/zonemoment_op.go index e07eb587..ef6a29dd 100644 --- a/api/proto/zonemoment/proto/zonemoment_op.go +++ b/api/proto/zonemoment/proto/zonemoment_op.go @@ -73,11 +73,12 @@ type OpListByMidReq struct { base.BaseRequest MType *int64 `json:"m_type"` // 媒体类型 Status *int64 `json:"status"` // 状态 - CtUpperBound *int64 `json:"ct_upper_bound"` //创建时间上界,闭区间 - CtLowerBound *int64 `json:"ct_lower_bound"` //创建时间下界,开区间,可为0 + CtUpperBound *int64 `json:"ct_upper_bound"` // 创建时间上界,闭区间 + CtLowerBound *int64 `json:"ct_lower_bound"` // 创建时间下界,开区间,可为0 Offset int `json:"offset"` Limit int `json:"limit"` Sort []string + Uid *int64 } type OpListByMidData struct { diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 8fa03fa7..d73dfb9b 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -4192,6 +4192,12 @@ func (m *Mongo) GetZoneMomentListByMid(ctx *gin.Context, req *zonemomentproto.Op "mid": req.GetBaseRequest().Mid, "del_flag": 0, } + if req.Uid != nil { + query["mid"] = util.DerefInt64(req.Uid) + } else { + query["mid"] = req.GetBaseRequest().Mid + } + if req.MType != nil { query["m_type"] = util.DerefInt64(req.MType) } diff --git a/app/mix/service/service.go b/app/mix/service/service.go index d77aab89..5269b764 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3385,6 +3385,7 @@ func (s *Service) OpGetZoneMomentListByUserId(ctx *gin.Context, req *zonemomentp list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ BaseRequest: req.BaseRequest, + Uid: account.Mid, CtUpperBound: req.CtUpperBound, CtLowerBound: req.CtLowerBound, }) From 1ac73882d1536332c5cfd4336b8a2ca0aae65c59 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 30 Apr 2024 09:51:23 +0800 Subject: [PATCH 2/2] by Robin at 20240430 --- api/consts/consts.go | 1 + app/mix/controller/config_op.go | 11 +++++++++++ app/mix/controller/init.go | 1 + app/mix/service/configservice.go | 15 +++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/api/consts/consts.go b/api/consts/consts.go index 38ae7b2a..35b5a644 100644 --- a/api/consts/consts.go +++ b/api/consts/consts.go @@ -51,6 +51,7 @@ const ( DefaultMomentTextKey = "default_moment_text" MaxDailyZoneMomentCreateTimesKey = "max_daily_zone_moment_create_times" ReferentialZoneMomentKey = "referential_zone_moment" + IsMomentImageEncryptEnabledKey = "is_moment_image_encrypt_enabled" ) // del_flag diff --git a/app/mix/controller/config_op.go b/app/mix/controller/config_op.go index 212caf2d..01daf725 100644 --- a/app/mix/controller/config_op.go +++ b/app/mix/controller/config_op.go @@ -70,3 +70,14 @@ func OpGetUploadMediaFailConfigList(ctx *gin.Context) { ReplyOk(ctx, config) } + +func OpGetIsMomentImageEncryptEnabled(ctx *gin.Context) { + isEnabled, ec := service.DefaultConfigService.OpGetIsMomentImageEncryptEnabled(ctx) + if ec != errcode.ErrCodeOk { + logger.Error("OpGetIsMomentImageEncryptEnabled fail, ec: %v", ec) + ReplyErrCodeMsg(ctx, ec) + return + } + + ReplyOk(ctx, isEnabled) +} diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index 2f8d2271..3d998f09 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -114,6 +114,7 @@ func Init(r *gin.Engine) { apiMomentGroup.POST("thumbs_up", middleware.JSONParamValidator(momentproto.ApiThumbsUpReq{}), middleware.JwtAuthenticator(), ApiThumbsUpMoment) apiMomentGroup.POST("list_by_ids", middleware.JSONParamValidator(momentproto.ApiListByIdsReq{}), middleware.JwtAuthenticator(), ApiGetMomentListByIds) apiMomentGroup.POST("recomm_list", middleware.JSONParamValidator(momentproto.ApiRecommListReq{}), middleware.JwtAuthenticator(), ApiGetMomentRecommList) + apiMomentGroup.POST("is_moment_image_encrypt_enabled", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), OpGetIsMomentImageEncryptEnabled) // 足迹 // apiFootPrintGroup := r.Group("/api/footprint", PrepareToC()) diff --git a/app/mix/service/configservice.go b/app/mix/service/configservice.go index 8b20ca92..19d86772 100644 --- a/app/mix/service/configservice.go +++ b/app/mix/service/configservice.go @@ -169,3 +169,18 @@ func (s *ConfigService) OpGetUploadMediaFailConfigList(ctx *gin.Context) (upload return } + +func (s *ConfigService) OpGetIsMomentImageEncryptEnabled(ctx *gin.Context) (isEnabled int64, ec errcode.ErrCode) { + ec = errcode.ErrCodeOk + + isMomentImageEncryptEnabled, err := apollo.GetIntValue(consts.IsMomentImageEncryptEnabledKey, apollo.ApolloOpts().SetNamespace("application")) + if err != nil { + logger.Error("Apollo read failed : %v", err) + ec = errcode.ErrCodeApolloReadFail + return + } + + isEnabled = int64(isMomentImageEncryptEnabled) + + return +}