Compare commits

..

No commits in common. "main" and "feat-hjj-BalanceLang" have entirely different histories.

4 changed files with 31 additions and 179 deletions

View File

@ -65,10 +65,6 @@ func NewRouter() *gin.Engine {
SupplierRouter(privateGroup)
{
v1.POST("version", version.Version) //版本号公共
v1.POST("store_versions", version.StoreBrandsVersions)
v1.POST("check_version", version.CheckBrandVersion)
v1.POST("store_listed", version.ListedStore)
v1.POST("check_listed", version.ListedCheck)
}
//账号模块
{

View File

@ -330,7 +330,7 @@ func SendMsg(c *gin.Context) {
req.Project = "fiee"
req.TelNum = req.Zone + req.TelNum
//todo 审核使用账号
if req.TelNum == "8618888888888" || req.TelNum == "8613580848136" {
if req.TelNum == "8618888888888" {
service.Success1(c, "发送成功", &account.SendMsgStatusResponse{})
return
}

View File

@ -867,11 +867,31 @@ func ArtistMetricsSeries(ctx *gin.Context) {
subNum = infoResp.SubNum
}
// 先串行获取艺人信息,以便用正确的 artistUUID 调用后续接口
subInfoResp, subInfoErr := service.AccountFieeProvider.SubNumGetInfo(context.Background(), &accountFiee.SubNumGetInfoRequest{
var subInfoResp *accountFiee.UserInfoResponse
var subInfoErr error
var workStatsResp *cast.GetArtistWorkStatsResp
var metricsResp *cast.ArtistMetricsSeriesResp
var workStatsErr, metricsErr error
wg := sync.WaitGroup{}
wg.Add(2)
// 并行调用 SubNumGetInfo、ArtistMetricsSeries
go func() {
defer wg.Done()
subInfoResp, subInfoErr = service.AccountFieeProvider.SubNumGetInfo(context.Background(), &accountFiee.SubNumGetInfoRequest{
SubNum: subNum,
Domain: "app",
})
}()
go func() {
defer wg.Done()
metricsResp, metricsErr = service.CastProvider.ArtistMetricsSeries(context.Background(), req)
}()
wg.Wait()
if subInfoErr != nil {
service.Error(ctx, errors.New("自媒体用户查询失败"))
return
@ -882,12 +902,8 @@ func ArtistMetricsSeries(ctx *gin.Context) {
}
req.ArtistUUID = fmt.Sprint(subInfoResp.Id)
// 使用正确的 artistUUID 调用 ArtistMetricsSeries
metricsResp, metricsErr := service.CastProvider.ArtistMetricsSeries(context.Background(), req)
// 将 ArtistMetricsSeriesReq 中 int 类型日期YYYYMMDD格式化为时间字符串作为快照截止时间
//默认时间为现在
statusUpdateTime := time.Now().Format("2006-01-02 15:04:05")
statusUpdateTime := ""
if req.Date > 0 {
parsedDate, parseErr := time.Parse("20060102", strconv.Itoa(int(req.Date)))
if parseErr == nil {
@ -896,7 +912,7 @@ func ArtistMetricsSeries(ctx *gin.Context) {
}
newCtx := NewCtxWithUserInfo(ctx)
workStatsResp, workStatsErr := service.CastProvider.GetArtistWorkStats(newCtx, &cast.GetArtistWorkStatsReq{
workStatsResp, workStatsErr = service.CastProvider.GetArtistWorkStats(newCtx, &cast.GetArtistWorkStatsReq{
ArtistUuid: req.ArtistUUID,
StatusUpdateTime: statusUpdateTime,
})

View File

@ -1,46 +1,16 @@
package version
import (
"encoding/json"
"errors"
"fmt"
"fonchain-fiee/pkg/cache"
"fonchain-fiee/pkg/model/query"
"fonchain-fiee/pkg/model/vo"
"fonchain-fiee/pkg/service"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-redis/redis"
)
// handlePanic 统一处理 panic 恢复
func handlePanic(c *gin.Context) {
if r := recover(); r != nil {
var err error
switch v := r.(type) {
case error:
err = v
case string:
err = fmt.Errorf("panic: %s", v)
default:
err = fmt.Errorf("panic: %v", v)
}
service.Error(c, err)
}
}
// containsVersion 检查版本是否存在于版本列表中
func containsVersion(versions []string, targetVersion string) bool {
for _, version := range versions {
if version == targetVersion {
return true
}
}
return false
}
func Version(c *gin.Context) {
var req query.VersionQuery
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
@ -55,136 +25,6 @@ func Version(c *gin.Context) {
}
service.Success(c, vo.VersionVo{Version: val})
}
func StoreBrandsVersions(c *gin.Context) {
defer handlePanic(c)
var brands []struct {
Brand string `json:"brand"`
Version []string `json:"version"`
}
if err := c.ShouldBindBodyWith(&brands, binding.JSON); err != nil {
service.Error(c, err)
return
}
for _, brand := range brands {
versionData, err := json.Marshal(brand.Version)
if err != nil {
service.Error(c, err)
return
}
if err = cache.RedisClient.HSet("brands_versions", brand.Brand, versionData).Err(); err != nil {
service.Error(c, err)
return
}
}
service.Success(c, true)
}
func CheckBrandVersion(c *gin.Context) {
defer handlePanic(c)
var brand struct {
Brand string `json:"brand"`
Version string `json:"version"`
}
if err := c.ShouldBindBodyWith(&brand, binding.JSON); err != nil {
service.Error(c, err)
return
}
storedVersionsStr, err := cache.RedisClient.HGet("brands_versions", brand.Brand).Result()
// 品牌不存在,返回 false
if errors.Is(err, redis.Nil) {
service.Success(c, false)
return
}
if err != nil {
service.Error(c, err)
return
}
var storedVersions []string
if err = json.Unmarshal([]byte(storedVersionsStr), &storedVersions); err != nil {
service.Error(c, err)
return
}
// 检查版本是否存在
versionFound := containsVersion(storedVersions, brand.Version)
service.Success(c, versionFound)
}
func ListedStore(c *gin.Context) {
defer handlePanic(c)
var brands []struct {
Brand string `json:"brand"`
Version []string `json:"version"`
}
if err := c.ShouldBindBodyWith(&brands, binding.JSON); err != nil {
service.Error(c, err)
return
}
for _, brand := range brands {
versionData, err := json.Marshal(brand.Version)
if err != nil {
service.Error(c, err)
return
}
if err = cache.RedisClient.HSet("brands_listed", brand.Brand, versionData).Err(); err != nil {
service.Error(c, err)
return
}
}
service.Success(c, true)
}
func ListedCheck(c *gin.Context) {
defer handlePanic(c)
var brand struct {
Brand string `json:"brand"`
Version string `json:"version"`
}
if err := c.ShouldBindBodyWith(&brand, binding.JSON); err != nil {
service.Error(c, err)
return
}
storedVersionsStr, err := cache.RedisClient.HGet("brands_listed", brand.Brand).Result()
// 品牌不存在,返回 false
if errors.Is(err, redis.Nil) {
service.Success(c, false)
return
}
if err != nil {
service.Error(c, err)
return
}
var storedVersions []string
if err = json.Unmarshal([]byte(storedVersionsStr), &storedVersions); err != nil {
service.Error(c, err)
return
}
// 检查版本是否存在
versionFound := containsVersion(storedVersions, brand.Version)
service.Success(c, versionFound)
return
}