|
@@ -2,6 +2,7 @@ package chart
|
|
|
|
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
|
|
+ "fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
"hongze/hongze_yb/controller/response"
|
|
"hongze/hongze_yb/controller/response"
|
|
"hongze/hongze_yb/global"
|
|
"hongze/hongze_yb/global"
|
|
@@ -358,16 +359,20 @@ func RefreshChartInfo(c *gin.Context) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+ userInfo := user.GetInfoByClaims(c)
|
|
-
|
|
+ cacheKey := utils.HZ_CHART_LIB_DETAIL + "YB_REFRESH_LIMIT_" + strconv.Itoa(chartInfoId) + "_" + strconv.Itoa(int(userInfo.UserID))
|
|
-
|
|
+ fmt.Println("refreshCacheKey:", cacheKey)
|
|
-
|
|
+ countUserRefresh, _ := global.Redis.Get(context.TODO(), cacheKey).Int()
|
|
-
|
|
+ if countUserRefresh >= 2 {
|
|
-
|
|
+ response.Ok("目前已是最新数据", c)
|
|
-
|
|
+ return
|
|
-
|
|
+ }
|
|
-
|
|
+ countUserRefresh += 1
|
|
|
|
+ now := time.Now()
|
|
|
|
+ today := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, time.Local)
|
|
|
|
+ sub := today.Sub(now)
|
|
|
|
+ _ = global.Redis.SetEX(context.TODO(), cacheKey, countUserRefresh, sub)
|
|
|
|
|
|
|
|
|
|
chartInfo, err := chartInfoModel.GetChartInfoById(chartInfoId)
|
|
chartInfo, err := chartInfoModel.GetChartInfoById(chartInfoId)
|