From 3dc9ca16656dc75237319c5f372b268accd9c226 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 14 May 2024 17:22:40 +0800 Subject: [PATCH 1/5] by Robin at 20240514 --- api/consts/option.go | 5 +++++ apollostruct/version.go | 6 ++++++ app/mix/service/apiservice.go | 29 ++++++++++++++++++----------- bizcommon/util/util.go | 27 +++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/api/consts/option.go b/api/consts/option.go index 115c3a69..a8bf1972 100644 --- a/api/consts/option.go +++ b/api/consts/option.go @@ -55,3 +55,8 @@ const ( ZoneMomentPriorityInZone_Increment = 2000000000 ZoneMomentPriorityInZone_Decrement = -2000000000 ) + +const ( + AppConfigReflect_Current = 1 // 符合当前版本的version做映射 + AppConfigReflect_LessThan = 2 // 小于当前版本的version做映射 +) diff --git a/apollostruct/version.go b/apollostruct/version.go index 31f5af3b..7de660b1 100644 --- a/apollostruct/version.go +++ b/apollostruct/version.go @@ -6,3 +6,9 @@ type Version struct { DownloadUrl string `json:"download_url"` Force bool `json:"force"` } + +type AppConfigReflect struct { + Type int64 `json:"type"` + Version string `json:"version"` + ReflectedKey string `json:"reflected_key"` +} diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index eb223878..ddb6aaf0 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -39,7 +39,6 @@ import ( "service/library/contentaudit/textaudit" videomoderation "service/library/contentaudit/video_moderation" "service/library/logger" - "strings" "time" "go.mongodb.org/mongo-driver/mongo" @@ -2078,24 +2077,32 @@ func (s *Service) ApiGetThumbsUpList(ctx *gin.Context, req *thumbsupproto.ApiLis func (s *Service) ApiGetAppConfigListByKey(ctx *gin.Context, req *appconfigproto.ApiListByKeyReq) (appconfig *dbstruct.AppConfig, ec errcode.ErrCode) { ec = errcode.ErrCodeAppConfigSrvOk - //读取版本下是否有字段需要进行版本映射 - appConfigReflect, err := apollo.GetStringValue(consts.AppConfigReflectKey+"_"+req.BaseRequest.Version, apollo.ApolloOpts().SetNamespace("version")) + configKey := req.ConfigKey + + // 判断key是否需要映射,以及映射类型 + cfg := apollostruct.AppConfigReflect{} + err := apollo.GetJson(consts.AppConfigReflectKey+"_"+req.ConfigKey, &cfg, apollo.ApolloOpts().SetNamespace("version")) if err != nil { - logger.Error("Apollo read failed : %v", err) ec = errcode.ErrCodeApolloReadFail + logger.Error("Apollo read failed : %v", err) return } - if appConfigReflect != "" { - appConfigReflectColumns := strings.Split(appConfigReflect, ";") - for _, column := range appConfigReflectColumns { - if req.ConfigKey == column { - req.ConfigKey = req.ConfigKey + "_" + req.BaseRequest.Version - } + if cfg.Type == consts.AppConfigReflect_Current && req.BaseRequest.Version == cfg.Version { + configKey = cfg.ReflectedKey + } else if cfg.Type == consts.AppConfigReflect_LessThan { + isInNeedOfReflection, err := util.VerisonCompare(cfg.Version, req.BaseRequest.Version) + if err != nil { + ec = errcode.ErrCodeApolloVersionFormatError + logger.Error("VerisonCompare failed : %v", err) + return + } + if isInNeedOfReflection { + configKey = cfg.ReflectedKey } } appconfig, err = _DefaultAppConfig.OpListByKey(ctx, &appconfigproto.OpListByKeyReq{ - ConfigKey: req.ConfigKey, + ConfigKey: configKey, }) if err != nil { logger.Error("OpGetAppConfigListByKey fail, req: %v, err: %v", util.ToJson(req), err) diff --git a/bizcommon/util/util.go b/bizcommon/util/util.go index 81b03334..bc694380 100644 --- a/bizcommon/util/util.go +++ b/bizcommon/util/util.go @@ -163,3 +163,30 @@ func String2Int32(s string) int32 { func String2Int64(s string) int64 { return int64(String2Int(s)) } + +func VerisonCompare(ver1 string, ver2 string) (bool, error) { + ver1SeqNos := strings.Split(ver1, ".") + ver2SeqNos := strings.Split(ver2, ".") + if len(ver1SeqNos) != len(ver2SeqNos) { + logger.Error("version format error") + return false, fmt.Errorf("version format error") + } + for i := range ver1SeqNos { + ver1SeqNo, err := strconv.Atoi(ver1SeqNos[i]) + if err != nil { + logger.Error("ver1 version format error:%v", err) + return false, err + } + ver2SeqNo, err := strconv.Atoi(ver2SeqNos[i]) + if err != nil { + logger.Error("ver2 version format error:%v", err) + return false, err + } + if ver1SeqNo > ver2SeqNo { + return true, nil + } else if ver1SeqNo < ver2SeqNo { + return false, nil + } + } + return false, nil +} From 1293757049f0d56b754a0ac10a502c296ff76611 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 14 May 2024 20:36:01 +0800 Subject: [PATCH 2/5] by Robin at 20240514 --- app/mix/dao/mongo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 82e8575f..ec943be2 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -4255,7 +4255,7 @@ func (m *Mongo) GetZoneMomentListByMid(ctx *gin.Context, req *zonemomentproto.Op } func (m *Mongo) ThumbsUpZoneMoment(ctx *gin.Context, req *zonemomentproto.OpZoneMomentThumbsUpReq) (err error) { - col := m.getColMoment() + col := m.getColZoneMoment() change := qmgo.Change{ Update: qmgo.M{"$inc": qmgo.M{"thumbs_up_num": util.DerefInt64(req.Times)}}, Upsert: true, From 4130795c11384d7e8a4b2a50cf9d711882599328 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 14 May 2024 20:47:20 +0800 Subject: [PATCH 3/5] by Robin at 20240514 --- app/mix/service/logic/zonemoment.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/mix/service/logic/zonemoment.go b/app/mix/service/logic/zonemoment.go index 91fc25a4..dcaabd91 100644 --- a/app/mix/service/logic/zonemoment.go +++ b/app/mix/service/logic/zonemoment.go @@ -37,6 +37,7 @@ func (p *ZoneMoment) OpCreate(ctx *gin.Context, req *zonemomentproto.OpCreateReq req.ZoneMoment.Ut = goproto.Int64(time.Now().Unix()) req.ZoneMoment.DelFlag = goproto.Int64(consts.Exist) req.ZoneMoment.IsHeaded = goproto.Int64(consts.IsHeaded_No) // 未置顶 + req.ZoneMoment.ThumbsUpNum = goproto.Int64(0) err = p.store.CreateZoneMoment(ctx, req.ZoneMoment) if err != nil { logger.Error("CreateZoneMoment fail, err: %v", err) From 17c25c5128960638ee6b406fc92c51775a10f072 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Wed, 15 May 2024 10:16:57 +0800 Subject: [PATCH 4/5] by Robin at 20240515 --- .../contentaudit/imageaudit/control_block.go | 2 +- library/mediafiller/mediafiller.go | 50 +++++++++++++++++++ library/mediafiller/mediafillerhelper.go | 39 +++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/library/contentaudit/imageaudit/control_block.go b/library/contentaudit/imageaudit/control_block.go index ae7bf5a3..499def1b 100644 --- a/library/contentaudit/imageaudit/control_block.go +++ b/library/contentaudit/imageaudit/control_block.go @@ -43,7 +43,7 @@ func NewImageAuditTaskBatchControlBlock(tasks []*dbstruct.ImageAuditTask, batchI imageIndex, taskIndex = ctrlBlock.RecordImage(taskCtrlBlock, &mediaFillables, imageIndex, taskIndex) } - mediafiller.FillList(&gin.Context{}, mediaFillables) + mediafiller.FillListInternal(&gin.Context{}, mediaFillables) return ctrlBlock } diff --git a/library/mediafiller/mediafiller.go b/library/mediafiller/mediafiller.go index d1035266..51eeee32 100644 --- a/library/mediafiller/mediafiller.go +++ b/library/mediafiller/mediafiller.go @@ -50,6 +50,10 @@ func (p *MediaFiller) GetFileServerDomain() string { //return defaultMediaFiller.fileServerDomainName } +func (p *MediaFiller) GetInternalFileServerDomain() string { + return "https://wishpal-ironfan-media.oss-cn-hangzhou.aliyuncs.com/" +} + func FillEntity(ctx *gin.Context, entity MediaFillable) error { videoIds := entity.GetVideoIds() videoMap, err := getVideoMapByIds(ctx, videoIds) @@ -134,3 +138,49 @@ func FillList(ctx *gin.Context, list []MediaFillable) error { return nil } + +func FillListInternal(ctx *gin.Context, list []MediaFillable) error { + imageIds := make([]int64, 0) + videoIds := make([]int64, 0) + + for _, v := range list { + imageIds = append(imageIds, v.GetImageIds()...) + videoIds = append(videoIds, v.GetVideoIds()...) + } + + videoMap, err := getVideoMapByIds(ctx, videoIds) + if err != nil { + logger.Error("mediafiller component getVideoMapByIds failed : %v", err) + return err + } + + // 获取视频封面 + for _, v := range videoMap { + imageIds = append(imageIds, v.CoverId) + } + imageMap, err := getImageMapByIds(ctx, imageIds) + if err != nil { + logger.Error("mediafiller component getImageMapByIds failed : %v", err) + return err + } + + for _, v := range list { + + images := make([]*dbstruct.ToCImage, 0) + videos := make([]*dbstruct.ToCVideo, 0) + for _, imageId := range v.GetImageIds() { + if image, ok := imageMap[imageId]; ok { + images = append(images, transToCImageInternal(image)) + } + } + for _, videoId := range v.GetVideoIds() { + if video, ok := videoMap[videoId]; ok { + videos = append(videos, transToCVideoInternal(video, imageMap[video.CoverId])) + } + } + v.SetImages(images) + v.SetVideos(videos) + } + + return nil +} diff --git a/library/mediafiller/mediafillerhelper.go b/library/mediafiller/mediafillerhelper.go index d43f1d43..ae4774fe 100644 --- a/library/mediafiller/mediafillerhelper.go +++ b/library/mediafiller/mediafillerhelper.go @@ -79,3 +79,42 @@ func transToCVideo(video *dbstruct.Video, coverImg *dbstruct.Image) *dbstruct.To } return ret } + +// todo +func transToCImageInternal(image *dbstruct.Image) *dbstruct.ToCImage { + if image == nil { + return nil + } + + // 选择内存最小的图片 + imgSrcId := image.SelectMinSizeOssId() + + return &dbstruct.ToCImage{ + Id: image.Id, + W: image.W, + H: image.H, + Fmt: image.Fmt, + Urls: []string{defaultMediaFiller.GetInternalFileServerDomain() + imgSrcId}, + } +} + +// todo +func transToCVideoInternal(video *dbstruct.Video, coverImg *dbstruct.Image) *dbstruct.ToCVideo { + if video == nil { + return nil + } + ret := &dbstruct.ToCVideo{ + Id: video.Id, + Dur: video.Dur, + CoverUrls: []string{}, + Urls: []string{defaultMediaFiller.GetInternalFileServerDomain() + video.SrcId}, + } + if coverImg != nil { + ret.CoverW = coverImg.W + ret.CoverH = coverImg.H + ret.CoverFmt = coverImg.Fmt + imgSrcId := coverImg.SelectMinSizeOssId() + ret.CoverUrls = []string{defaultMediaFiller.GetInternalFileServerDomain() + imgSrcId} + } + return ret +} From c12b1e1164ce7650cd145bcd8488b23c18b04550 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Wed, 15 May 2024 12:40:21 +0800 Subject: [PATCH 5/5] fix --- app/mix/controller/vas.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/mix/controller/vas.go b/app/mix/controller/vas.go index dd20e1f8..becfcec0 100644 --- a/app/mix/controller/vas.go +++ b/app/mix/controller/vas.go @@ -266,8 +266,8 @@ func WithdrawApply(ctx *gin.Context) { ReplyErrorMsg(ctx, "当前提现功能已冻结") return } - if req.Diamonds < 2000 { - ReplyErrorMsg(ctx, "最低提现金额不能小于200元") + if req.Diamonds < 1000 { + ReplyErrorMsg(ctx, "最低提现金额不能小于100元") return } if !vasproto.IsWithdrawAnyDiasEnable(req.Mid) && req.Diamonds > 20000 {