Browse Source

Merge branch 'feature/pool325_report_public' into debug

xyxie 2 months ago
parent
commit
e4776e1935
1 changed files with 21 additions and 0 deletions
  1. 21 0
      services/report_v2.go

+ 21 - 0
services/report_v2.go

@@ -135,6 +135,7 @@ func AddReportAndChapter(reportInfo *models.Report, inheritReportId int, grantAd
 // @return errMsg string
 func EditReport(reportInfo *models.Report, req models.EditReq, sysUser *system.Admin) (err error, errMsg string) {
 	errMsg = `保存失败`
+	oldIsPublicPublish := reportInfo.IsPublicPublish
 	//var stage int
 	//if reportInfo.ClassifyNameFirst != req.ClassifyNameFirst || reportInfo.ClassifyNameSecond != req.ClassifyNameSecond {
 	//	// 报告期数
@@ -269,6 +270,26 @@ func EditReport(reportInfo *models.Report, req models.EditReq, sysUser *system.A
 		go handleReportPermission(int64(reportInfo.Id), minClassifyId)
 	}
 
+	// 更新es里的章节数据
+	if oldIsPublicPublish != reportInfo.IsPublicPublish {
+		if reportInfo.HasChapter == 1 {
+			// 晨周报
+			chapterList, tmpErr := models.GetPublishedChapterListByReportId(reportInfo.Id)
+			if tmpErr != nil {
+				return
+			}
+			if len(chapterList) > 0 {
+				// 更新章节的es数据
+				for _, chapterInfo := range chapterList {
+					err = updateReportChapterEsByChapter(chapterInfo, reportInfo.IsPublicPublish)
+					if err != nil {
+						return
+					}
+				}
+			}
+		}
+	}
+
 	return
 }