Browse Source

fix:修复研报添加版头,然后在版图素材库中删掉该版头,提示操作失败,并清空了研报内容

Roc 2 months ago
parent
commit
ab4c1783e9
2 changed files with 20 additions and 12 deletions
  1. 10 6
      services/report/report.go
  2. 10 6
      services/report/report_chapter.go

+ 10 - 6
services/report/report.go

@@ -461,22 +461,26 @@ func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail respons
 	{
 	{
 		if reportInfo.HeadResourceId > 0 {
 		if reportInfo.HeadResourceId > 0 {
 			headResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.HeadResourceId)
 			headResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.HeadResourceId)
-			if tmpErr != nil {
+			if tmpErr != nil && tmpErr != utils.ErrNoRow {
 				err = tmpErr
 				err = tmpErr
 				return
 				return
 			}
 			}
-			reportItem.HeadImg = headResource.ImgURL
-			reportItem.HeadStyle = headResource.Style
+			if headResource != nil && headResource.ResourceID > 0 {
+				reportItem.HeadImg = headResource.ImgURL
+				reportItem.HeadStyle = headResource.Style
+			}
 		}
 		}
 
 
 		if reportInfo.EndResourceId > 0 {
 		if reportInfo.EndResourceId > 0 {
 			endResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.EndResourceId)
 			endResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.EndResourceId)
-			if tmpErr != nil {
+			if tmpErr != nil && tmpErr != utils.ErrNoRow {
 				err = tmpErr
 				err = tmpErr
 				return
 				return
 			}
 			}
-			reportItem.EndImg = endResource.ImgURL
-			reportItem.EndStyle = endResource.Style
+			if endResource != nil && endResource.ResourceID > 0 {
+				reportItem.EndImg = endResource.ImgURL
+				reportItem.EndStyle = endResource.Style
+			}
 		}
 		}
 	}
 	}
 
 

+ 10 - 6
services/report/report_chapter.go

@@ -271,22 +271,26 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 	{
 	{
 		if reportInfo.HeadResourceId > 0 {
 		if reportInfo.HeadResourceId > 0 {
 			headResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.HeadResourceId)
 			headResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.HeadResourceId)
-			if tmpErr != nil {
+			if tmpErr != nil && tmpErr != utils.ErrNoRow {
 				err = tmpErr
 				err = tmpErr
 				return
 				return
 			}
 			}
-			reportChapterItem.HeadImg = headResource.ImgURL
-			reportChapterItem.HeadStyle = headResource.Style
+			if headResource != nil && headResource.ResourceID > 0 {
+				reportChapterItem.HeadImg = headResource.ImgURL
+				reportChapterItem.HeadStyle = headResource.Style
+			}
 		}
 		}
 
 
 		if reportInfo.EndResourceId > 0 {
 		if reportInfo.EndResourceId > 0 {
 			endResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.EndResourceId)
 			endResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.EndResourceId)
-			if tmpErr != nil {
+			if tmpErr != nil && tmpErr != utils.ErrNoRow {
 				err = tmpErr
 				err = tmpErr
 				return
 				return
 			}
 			}
-			reportChapterItem.EndImg = endResource.ImgURL
-			reportChapterItem.EndStyle = endResource.Style
+			if endResource != nil && endResource.ResourceID > 0 {
+				reportChapterItem.EndImg = endResource.ImgURL
+				reportChapterItem.EndStyle = endResource.Style
+			}
 		}
 		}
 	}
 	}