浏览代码

Merge branch 'bug/7199' into debug

# Conflicts:
#	controllers/report_share.go
Roc 2 月之前
父节点
当前提交
dabd009468
共有 2 个文件被更改,包括 24 次插入15 次删除
  1. 12 7
      controllers/report_share.go
  2. 12 8
      controllers/smart_report.go

+ 12 - 7
controllers/report_share.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"eta/eta_report/models"
 	"eta/eta_report/services"
+	"eta/eta_report/utils"
 	"fmt"
 	"html"
 	"strings"
@@ -47,24 +48,28 @@ func (this *ReportShareController) Detail() {
 
 	if report.HeadResourceId > 0 {
 		headResource, err := models.GetResourceItemById(report.HeadResourceId)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取资源库版头失败, Err: " + err.Error()
 			return
 		}
-		report.HeadImg = headResource.ImgUrl
-		report.HeadStyle = headResource.Style
+		if headResource != nil && headResource.ResourceId > 0 {
+			report.HeadImg = headResource.ImgUrl
+			report.HeadStyle = headResource.Style
+		}
 	}
 
 	if report.EndResourceId > 0 {
 		endResource, err := models.GetResourceItemById(report.EndResourceId)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "操作失败"
-			br.ErrMsg = "获取资源库版失败, Err: " + err.Error()
+			br.ErrMsg = "获取资源库版失败, Err: " + err.Error()
 			return
 		}
-		report.EndImg = endResource.ImgUrl
-		report.EndStyle = endResource.Style
+		if endResource != nil && endResource.ResourceId > 0 {
+			report.EndImg = endResource.ImgUrl
+			report.EndStyle = endResource.Style
+		}
 	}
 
 	resp := new(models.ReportShareDetailResp)

+ 12 - 8
controllers/smart_report.go

@@ -53,24 +53,28 @@ func (this *SmartReportController) Detail() {
 	resp.Report = models.FormatSmartReport2Item(item)
 	if resp.Report.HeadResourceId > 0 {
 		headResource, err := models.GetResourceItemById(resp.Report.HeadResourceId)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "操作失败"
-			br.ErrMsg = "获取资源库版头失败, Err: " + e.Error()
+			br.ErrMsg = "获取资源库版头失败, Err: " + err.Error()
 			return
 		}
-		resp.Report.HeadImg = headResource.ImgUrl
-		resp.Report.HeadStyle = headResource.Style
+		if headResource != nil && headResource.ResourceId > 0 {
+			resp.Report.HeadImg = headResource.ImgUrl
+			resp.Report.HeadStyle = headResource.Style
+		}
 	}
 
 	if resp.Report.EndResourceId > 0 {
 		endResource, err := models.GetResourceItemById(resp.Report.EndResourceId)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "操作失败"
-			br.ErrMsg = "获取资源库版头失败, Err: " + e.Error()
+			br.ErrMsg = "获取资源库版尾失败, Err: " + err.Error()
 			return
 		}
-		resp.Report.EndImg = endResource.ImgUrl
-		resp.Report.EndStyle = endResource.Style
+		if endResource != nil && endResource.ResourceId > 0 {
+			resp.Report.EndImg = endResource.ImgUrl
+			resp.Report.EndStyle = endResource.Style
+		}
 	}
 	// 免责声明
 	conf, e := models.GetBusinessConf()