|
@@ -1215,7 +1215,7 @@ func PublishReport(reportId int, reportUrl string, sysUser *system.Admin) (tips
|
|
|
|
|
|
// 生成报告pdf和长图
|
|
|
{
|
|
|
- reportPdfUrl := GetGeneralPdfUrl(reportInfo.ReportCode, reportInfo.ReportLayout)
|
|
|
+ reportPdfUrl := GetGeneralPdfUrl(reportInfo.Id, reportInfo.ReportCode, reportInfo.ReportLayout)
|
|
|
go Report2pdfAndJpeg(reportPdfUrl, reportId, 1)
|
|
|
}
|
|
|
|
|
@@ -1342,7 +1342,7 @@ func PublishChapterReport(reportInfo *models.Report, reportUrl string, sysUser *
|
|
|
|
|
|
// 生成报告pdf和长图
|
|
|
{
|
|
|
- reportPdfUrl := GetGeneralPdfUrl(reportInfo.ReportCode, reportInfo.ReportLayout)
|
|
|
+ reportPdfUrl := GetGeneralPdfUrl(reportInfo.Id, reportInfo.ReportCode, reportInfo.ReportLayout)
|
|
|
go Report2pdfAndJpeg(reportPdfUrl, reportId, 1)
|
|
|
}
|
|
|
|
|
@@ -1503,7 +1503,7 @@ func UpdateReportVideo(reportInfo *models.Report) {
|
|
|
// @param reportCode string
|
|
|
// @param reportLayout int8
|
|
|
// @return pdfUrl string
|
|
|
-func GetGeneralPdfUrl(reportCode string, reportLayout int8) (pdfUrl string) {
|
|
|
+func GetGeneralPdfUrl(reportId int, reportCode string, reportLayout int8) (pdfUrl string) {
|
|
|
conf, e := models.GetBusinessConfByKey("ReportViewUrl")
|
|
|
if e != nil {
|
|
|
return
|
|
@@ -1518,6 +1518,14 @@ func GetGeneralPdfUrl(reportCode string, reportLayout int8) (pdfUrl string) {
|
|
|
pdfUrl = fmt.Sprintf("%s/reportshare_smart_pdf?code=%s", conf.ConfVal, reportCode)
|
|
|
}
|
|
|
|
|
|
+ if pdfUrl != "" {
|
|
|
+ token := utils.MD5(fmt.Sprint(pdfUrl, time.Now().UnixNano()/1e6))
|
|
|
+ e := generalReportAuthToken(token, reportId)
|
|
|
+ if e == nil {
|
|
|
+ pdfUrl = fmt.Sprintf("%s&authToken=%s", pdfUrl, token)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1682,6 +1690,80 @@ func GeneralChartToken(showType, uniqueCode string, expireTime time.Duration) (t
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// GeneralReportToken
|
|
|
+// @Description: 生成报告授权token
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-01-07 10:41:36
|
|
|
+// @param uniqueCode string
|
|
|
+// @return token string
|
|
|
+// @return err error
|
|
|
+func GeneralReportToken(linkToken string, reportId int) (token string, err error) {
|
|
|
+ // 图表授权token
|
|
|
+ token = utils.MD5(fmt.Sprint(linkToken, time.Now().UnixNano()/1e6))
|
|
|
+
|
|
|
+ // 缓存key
|
|
|
+ reportKey := getReportShareTokenKey(linkToken)
|
|
|
+ err = utils.Rc.Put(reportKey, token, utils.BusinessConfReportChartExpiredTime)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成报告的图表授权token
|
|
|
+ err = generalReportAuthToken(token, reportId)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// generalReportAuthToken
|
|
|
+// @Description: 生成报告的图表授权token
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-03-17 17:47:07
|
|
|
+// @param token string
|
|
|
+// @param reportId int
|
|
|
+// @return err error
|
|
|
+func generalReportAuthToken(token string, reportId int) (err error) {
|
|
|
+ // 缓存key
|
|
|
+ reportTokenKey := getReportTokenKey(token)
|
|
|
+ err = utils.Rc.Put(reportTokenKey, reportId, utils.BusinessConfReportChartExpiredTime)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// getReportShareTokenKey
|
|
|
+// @Description:
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-03-17 14:00:14
|
|
|
+// @param linkToken string
|
|
|
+// @return string
|
|
|
+func getReportShareTokenKey(linkToken string) string {
|
|
|
+ return fmt.Sprint(utils.CACHE_REPORT_SHARE_AUTH, utils.MD5(linkToken))
|
|
|
+}
|
|
|
+
|
|
|
+// GetReportAuthToken
|
|
|
+// @Description: 获取报告token
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-03-17 16:48:38
|
|
|
+// @param linkToken string
|
|
|
+// @return string
|
|
|
+func GetReportAuthToken(linkToken string) string {
|
|
|
+ key := getReportShareTokenKey(linkToken)
|
|
|
+ return utils.Rc.GetStr(key)
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// getReportTokenKey
|
|
|
+// @Description:
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-03-17 14:00:14
|
|
|
+// @param linkToken string
|
|
|
+// @return string
|
|
|
+func getReportTokenKey(token string) string {
|
|
|
+ return fmt.Sprint(utils.CACHE_REPORT_AUTH, token)
|
|
|
+}
|
|
|
+
|
|
|
// HandleReportContentStruct
|
|
|
// @Description: 处理内容组件的链接
|
|
|
// @author: Roc
|
|
@@ -1756,6 +1838,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, req.ReportId)
|
|
|
+ }
|
|
|
+ }()
|
|
|
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(fmt.Sprint(utils.CACHE_REPORT_SHARE_ORIGIN_Url, utils.MD5(linkToken))) {
|
|
@@ -1813,6 +1900,12 @@ func TransfromToOriginUrl(linkToken string) (originLink string, msg string, err
|
|
|
msg = "链接已失效, 请重新获取"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ reportToken := GetReportAuthToken(linkToken)
|
|
|
+ if reportToken != "" {
|
|
|
+ originLink += `&authToken=` + reportToken
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|