Merge remote-tracking branch 'origin/main' into feat-IRONFANS-120-Robin

This commit is contained in:
Leufolium 2024-05-15 16:30:50 +08:00
commit c0698c2da3
10 changed files with 150 additions and 15 deletions

View File

@ -55,3 +55,8 @@ const (
ZoneMomentPriorityInZone_Increment = 2000000000 ZoneMomentPriorityInZone_Increment = 2000000000
ZoneMomentPriorityInZone_Decrement = -2000000000 ZoneMomentPriorityInZone_Decrement = -2000000000
) )
const (
AppConfigReflect_Current = 1 // 符合当前版本的version做映射
AppConfigReflect_LessThan = 2 // 小于当前版本的version做映射
)

View File

@ -6,3 +6,9 @@ type Version struct {
DownloadUrl string `json:"download_url"` DownloadUrl string `json:"download_url"`
Force bool `json:"force"` Force bool `json:"force"`
} }
type AppConfigReflect struct {
Type int64 `json:"type"`
Version string `json:"version"`
ReflectedKey string `json:"reflected_key"`
}

View File

@ -266,8 +266,8 @@ func WithdrawApply(ctx *gin.Context) {
ReplyErrorMsg(ctx, "当前提现功能已冻结") ReplyErrorMsg(ctx, "当前提现功能已冻结")
return return
} }
if req.Diamonds < 2000 { if req.Diamonds < 1000 {
ReplyErrorMsg(ctx, "最低提现金额不能小于200元") ReplyErrorMsg(ctx, "最低提现金额不能小于100元")
return return
} }
if !vasproto.IsWithdrawAnyDiasEnable(req.Mid) && req.Diamonds > 20000 { if !vasproto.IsWithdrawAnyDiasEnable(req.Mid) && req.Diamonds > 20000 {

View File

@ -4278,7 +4278,7 @@ func (m *Mongo) GetZoneMomentListByMid(ctx *gin.Context, req *zonemomentproto.Op
} }
func (m *Mongo) ThumbsUpZoneMoment(ctx *gin.Context, req *zonemomentproto.OpZoneMomentThumbsUpReq) (err error) { func (m *Mongo) ThumbsUpZoneMoment(ctx *gin.Context, req *zonemomentproto.OpZoneMomentThumbsUpReq) (err error) {
col := m.getColMoment() col := m.getColZoneMoment()
change := qmgo.Change{ change := qmgo.Change{
Update: qmgo.M{"$inc": qmgo.M{"thumbs_up_num": util.DerefInt64(req.Times)}}, Update: qmgo.M{"$inc": qmgo.M{"thumbs_up_num": util.DerefInt64(req.Times)}},
Upsert: true, Upsert: true,

View File

@ -39,7 +39,6 @@ import (
"service/library/contentaudit/textaudit" "service/library/contentaudit/textaudit"
videomoderation "service/library/contentaudit/video_moderation" videomoderation "service/library/contentaudit/video_moderation"
"service/library/logger" "service/library/logger"
"strings"
"time" "time"
"go.mongodb.org/mongo-driver/mongo" "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) { func (s *Service) ApiGetAppConfigListByKey(ctx *gin.Context, req *appconfigproto.ApiListByKeyReq) (appconfig *dbstruct.AppConfig, ec errcode.ErrCode) {
ec = errcode.ErrCodeAppConfigSrvOk ec = errcode.ErrCodeAppConfigSrvOk
//读取版本下是否有字段需要进行版本映射 configKey := req.ConfigKey
appConfigReflect, err := apollo.GetStringValue(consts.AppConfigReflectKey+"_"+req.BaseRequest.Version, apollo.ApolloOpts().SetNamespace("version"))
// 判断key是否需要映射以及映射类型
cfg := apollostruct.AppConfigReflect{}
err := apollo.GetJson(consts.AppConfigReflectKey+"_"+req.ConfigKey, &cfg, apollo.ApolloOpts().SetNamespace("version"))
if err != nil { if err != nil {
logger.Error("Apollo read failed : %v", err)
ec = errcode.ErrCodeApolloReadFail ec = errcode.ErrCodeApolloReadFail
logger.Error("Apollo read failed : %v", err)
return return
} }
if appConfigReflect != "" { if cfg.Type == consts.AppConfigReflect_Current && req.BaseRequest.Version == cfg.Version {
appConfigReflectColumns := strings.Split(appConfigReflect, ";") configKey = cfg.ReflectedKey
for _, column := range appConfigReflectColumns { } else if cfg.Type == consts.AppConfigReflect_LessThan {
if req.ConfigKey == column { isInNeedOfReflection, err := util.VerisonCompare(cfg.Version, req.BaseRequest.Version)
req.ConfigKey = req.ConfigKey + "_" + 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{ appconfig, err = _DefaultAppConfig.OpListByKey(ctx, &appconfigproto.OpListByKeyReq{
ConfigKey: req.ConfigKey, ConfigKey: configKey,
}) })
if err != nil { if err != nil {
logger.Error("OpGetAppConfigListByKey fail, req: %v, err: %v", util.ToJson(req), err) logger.Error("OpGetAppConfigListByKey fail, req: %v, err: %v", util.ToJson(req), err)

View File

@ -37,6 +37,7 @@ func (p *ZoneMoment) OpCreate(ctx *gin.Context, req *zonemomentproto.OpCreateReq
req.ZoneMoment.Ut = goproto.Int64(time.Now().Unix()) req.ZoneMoment.Ut = goproto.Int64(time.Now().Unix())
req.ZoneMoment.DelFlag = goproto.Int64(consts.Exist) req.ZoneMoment.DelFlag = goproto.Int64(consts.Exist)
req.ZoneMoment.IsHeaded = goproto.Int64(consts.IsHeaded_No) // 未置顶 req.ZoneMoment.IsHeaded = goproto.Int64(consts.IsHeaded_No) // 未置顶
req.ZoneMoment.ThumbsUpNum = goproto.Int64(0)
err = p.store.CreateZoneMoment(ctx, req.ZoneMoment) err = p.store.CreateZoneMoment(ctx, req.ZoneMoment)
if err != nil { if err != nil {
logger.Error("CreateZoneMoment fail, err: %v", err) logger.Error("CreateZoneMoment fail, err: %v", err)

View File

@ -163,3 +163,30 @@ func String2Int32(s string) int32 {
func String2Int64(s string) int64 { func String2Int64(s string) int64 {
return int64(String2Int(s)) 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
}

View File

@ -43,7 +43,7 @@ func NewImageAuditTaskBatchControlBlock(tasks []*dbstruct.ImageAuditTask, batchI
imageIndex, taskIndex = ctrlBlock.RecordImage(taskCtrlBlock, &mediaFillables, imageIndex, taskIndex) imageIndex, taskIndex = ctrlBlock.RecordImage(taskCtrlBlock, &mediaFillables, imageIndex, taskIndex)
} }
mediafiller.FillList(&gin.Context{}, mediaFillables) mediafiller.FillListInternal(&gin.Context{}, mediaFillables)
return ctrlBlock return ctrlBlock
} }

View File

@ -50,6 +50,10 @@ func (p *MediaFiller) GetFileServerDomain() string {
//return defaultMediaFiller.fileServerDomainName //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 { func FillEntity(ctx *gin.Context, entity MediaFillable) error {
videoIds := entity.GetVideoIds() videoIds := entity.GetVideoIds()
videoMap, err := getVideoMapByIds(ctx, videoIds) videoMap, err := getVideoMapByIds(ctx, videoIds)
@ -134,3 +138,49 @@ func FillList(ctx *gin.Context, list []MediaFillable) error {
return nil 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
}

View File

@ -79,3 +79,42 @@ func transToCVideo(video *dbstruct.Video, coverImg *dbstruct.Image) *dbstruct.To
} }
return ret 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
}