|
@@ -4,6 +4,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"eta/eta_report/models"
|
|
|
"eta/eta_report/services"
|
|
|
+ "eta/eta_report/utils"
|
|
|
"fmt"
|
|
|
"html"
|
|
|
"strings"
|
|
@@ -35,6 +36,7 @@ func (this *ReportShareController) Detail() {
|
|
|
br.ErrMsg = "参数错误,reportCode 为空"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
report, err := models.GetReportByCode(reportCode)
|
|
|
if err != nil {
|
|
|
br.Msg = "该报告已删除"
|
|
@@ -164,16 +166,32 @@ func (this *ReportShareController) Detail() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ var hasAuth bool
|
|
|
+ authToken := this.GetString("AuthToken")
|
|
|
+ if authToken != "" {
|
|
|
+ key := fmt.Sprint(utils.CACHE_REPORT_AUTH, authToken)
|
|
|
+ redisReportId, err := utils.Rc.GetUInt64(key)
|
|
|
+ if err == nil && int(redisReportId) == report.Id {
|
|
|
+ hasAuth = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 报告内图表授权
|
|
|
if v, ok := conf[models.BusinessConfIsOpenChartExpired]; ok {
|
|
|
if v == `true` {
|
|
|
- tokenMap := make(map[string]string)
|
|
|
- report.Content = services.HandleReportContent(report.Content, "add", tokenMap)
|
|
|
- //report.ContentStruct = services.HandleReportContent(report.ContentStruct, "add", tokenMap)
|
|
|
+ resp.IsOpenChartExpired = true
|
|
|
|
|
|
- for _, v := range reportChapters {
|
|
|
- v.Content = services.HandleReportContent(v.Content, "add", tokenMap)
|
|
|
+ // 有权限才会添加token
|
|
|
+ if hasAuth {
|
|
|
+ tokenMap := make(map[string]string)
|
|
|
+ report.Content = services.HandleReportContent(report.Content, "add", tokenMap)
|
|
|
+ //report.ContentStruct = services.HandleReportContent(report.ContentStruct, "add", tokenMap)
|
|
|
+
|
|
|
+ for _, v := range reportChapters {
|
|
|
+ v.Content = services.HandleReportContent(v.Content, "add", tokenMap)
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|