|
@@ -2078,15 +2078,37 @@ func GeneralChartToken(showType, uniqueCode string) (token string, err error) {
|
|
|
// @param uniqueCode string
|
|
|
// @return token string
|
|
|
// @return err error
|
|
|
-func GeneralReportToken(uniqueCode string) (token string, err error) {
|
|
|
+func GeneralReportToken(linkToken string) (token string, err error) {
|
|
|
// 缓存key
|
|
|
- token = utils.MD5(fmt.Sprint(uniqueCode, time.Now().UnixNano()/1e6))
|
|
|
- key := fmt.Sprint(utils.CACHE_REPORT_AUTH, token)
|
|
|
- err = utils.Rc.Put(key, uniqueCode, utils.BusinessConfReportChartExpiredTime)
|
|
|
+ token = utils.MD5(fmt.Sprint(linkToken, time.Now().UnixNano()/1e6))
|
|
|
+ key := getReportTokenKey(linkToken)
|
|
|
+ err = utils.Rc.Put(key, token, utils.BusinessConfReportChartExpiredTime)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// GetReportToken
|
|
|
+// @Description: 获取报告token
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-03-17 14:02:29
|
|
|
+// @param linkToken string
|
|
|
+// @return string
|
|
|
+func GetReportToken(linkToken string) string {
|
|
|
+ key := getReportTokenKey(linkToken)
|
|
|
+ return utils.Rc.GetStr(key)
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// getReportTokenKey
|
|
|
+// @Description:
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-03-17 14:00:14
|
|
|
+// @param linkToken string
|
|
|
+// @return string
|
|
|
+func getReportTokenKey(linkToken string) string {
|
|
|
+ return fmt.Sprint(utils.CACHE_REPORT_AUTH, utils.MD5(linkToken))
|
|
|
+}
|
|
|
+
|
|
|
// HandleReportContentStruct
|
|
|
// @Description: 处理内容组件的链接
|
|
|
// @author: Roc
|
|
@@ -2173,6 +2195,11 @@ func processMap(data map[string]interface{}, opType string, tokenMap map[string]
|
|
|
|
|
|
// GetReportShareUrlToken 获取报告分享链接token
|
|
|
func GetReportShareUrlToken(req models.ReportShartUrlReq, adminId int) (linkToken string, err error) {
|
|
|
+ defer func() {
|
|
|
+ if err == nil && linkToken != `` {
|
|
|
+ GeneralReportToken(linkToken)
|
|
|
+ }
|
|
|
+ }()
|
|
|
cacheLinkKey := utils.CACHE_REPORT_SHARE_SHORT_Url + strconv.Itoa(req.ReportId) + "userId:" + strconv.Itoa(adminId)
|
|
|
linkToken, _ = utils.Rc.RedisString(cacheLinkKey)
|
|
|
if linkToken != "" && utils.Rc.IsExist(utils.CACHE_REPORT_SHARE_ORIGIN_Url+linkToken) {
|
|
@@ -2230,6 +2257,12 @@ func TransfromToOriginUrl(linkToken string) (originLink string, msg string, err
|
|
|
msg = "链接已失效, 请重新获取"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ reportToken := GetReportToken(linkToken)
|
|
|
+ if reportToken != "" {
|
|
|
+ originLink += `&AuthToken=` + reportToken
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|