Преглед изворни кода

Merge branch 'feature/pool325_report_public' of eta_server/eta_api into master

xyxie пре 3 недеља
родитељ
комит
c793f3d381
6 измењених фајлова са 37 додато и 6 уклоњено
  1. 6 0
      controllers/report.go
  2. 2 2
      controllers/report_chapter.go
  3. 1 0
      models/report.go
  4. 1 0
      services/elastic.go
  5. 6 4
      services/report.go
  6. 21 0
      services/report_v2.go

+ 6 - 0
controllers/report.go

@@ -1919,6 +1919,12 @@ func (this *ReportController) SendMsg() {
 		return
 	}
 
+	//
+	if reportInfo.IsPublicPublish != 1 {
+		br.Msg = "报告未公开"
+		return
+	}
+
 	// 更新报告发布时间
 	videoNameDate := `(` + time.Now().Format("0102") + `)`
 	if err = models.UpdateReportPublishTime(req.ReportId, videoNameDate); err != nil {

+ 2 - 2
controllers/report_chapter.go

@@ -1368,7 +1368,7 @@ func (this *ReportController) PublishDayWeekReportChapter() {
 
 	// 更新章节ES
 	{
-		go services.UpdateReportChapterEs(chapterInfo.ReportChapterId)
+		go services.UpdateReportChapterEs(chapterInfo.ReportChapterId, reportInfo.IsPublicPublish)
 	}
 
 	// 同时发布报告
@@ -1652,7 +1652,7 @@ func (this *ReportController) CancelPublishReportChapter() {
 
 	// 更新章节ES
 	{
-		go services.UpdateReportChapterEs(chapterInfo.ReportChapterId)
+		go services.UpdateReportChapterEs(chapterInfo.ReportChapterId, reportInfo.IsPublicPublish)
 	}
 
 	br.Ret = 200

+ 1 - 0
models/report.go

@@ -997,6 +997,7 @@ type ElasticReportDetail struct {
 	BodyContent        string `description:"内容"`
 	PublishTime        string `description:"发布时间"`
 	PublishState       int    `description:"发布状态 1-未发布 2-已发布"`
+	IsPublicPublish    int8   `description:"是否公开发布,1:是,2:否"`
 	Author             string `description:"作者"`
 	ClassifyIdFirst    int    `description:"一级分类ID"`
 	ClassifyNameFirst  string `description:"一级分类名称"`

+ 1 - 0
services/elastic.go

@@ -102,6 +102,7 @@ func EsAddOrEditReport(indexName, docId string, item *models.ElasticReportDetail
 			"BodyContent":        item.BodyContent,
 			"PublishTime":        item.PublishTime,
 			"PublishState":       item.PublishState,
+			"IsPublicPublish":    item.IsPublicPublish,
 			"Author":             item.Author,
 			"ClassifyIdFirst":    item.ClassifyIdFirst,
 			"ClassifyNameFirst":  item.ClassifyNameFirst,

+ 6 - 4
services/report.go

@@ -143,7 +143,7 @@ func UpdateReportEs(reportId int, publishState int) (err error) {
 		if len(chapterList) > 0 {
 			// 更新章节的es数据
 			for _, chapterInfo := range chapterList {
-				err = updateReportChapterEsByChapter(chapterInfo)
+				err = updateReportChapterEsByChapter(chapterInfo, reportInfo.IsPublicPublish)
 				if err != nil {
 					return
 				}
@@ -183,6 +183,7 @@ func UpdateReportEs(reportId int, publishState int) (err error) {
 		BodyContent:        utils.TrimHtml(html.UnescapeString(reportInfo.Content)),
 		PublishTime:        reportInfo.PublishTime.Format(utils.FormatDateTime),
 		PublishState:       publishState,
+		IsPublicPublish:    reportInfo.IsPublicPublish,
 		Author:             reportInfo.Author,
 		ClassifyIdFirst:    reportInfo.ClassifyIdFirst,
 		ClassifyNameFirst:  reportInfo.ClassifyNameFirst,
@@ -241,7 +242,7 @@ func addCategoryAliasToArr(categoryArr []string) (aliasArr []string, err error)
 // @datetime 2024-06-20 13:16:22
 // @param reportChapterId int
 // @return err error
-func UpdateReportChapterEs(reportChapterId int) (err error) {
+func UpdateReportChapterEs(reportChapterId int, isPublicPublish int8) (err error) {
 	if reportChapterId <= 0 {
 		return
 	}
@@ -250,7 +251,7 @@ func UpdateReportChapterEs(reportChapterId int) (err error) {
 		return
 	}
 
-	err = updateReportChapterEsByChapter(chapterInfo)
+	err = updateReportChapterEsByChapter(chapterInfo, isPublicPublish)
 	if err != nil {
 		return
 	}
@@ -264,7 +265,7 @@ func UpdateReportChapterEs(reportChapterId int) (err error) {
 // @datetime 2024-06-20 13:16:11
 // @param chapterInfo *models.ReportChapter
 // @return err error
-func updateReportChapterEsByChapter(chapterInfo *models.ReportChapter) (err error) {
+func updateReportChapterEsByChapter(chapterInfo *models.ReportChapter, isPublicPublish int8) (err error) {
 	// 章节对应的品种
 	obj := report.ReportChapterPermissionMapping{}
 	permissionList, tmpErr := obj.GetPermissionItemListById(chapterInfo.ReportChapterId)
@@ -289,6 +290,7 @@ func updateReportChapterEsByChapter(chapterInfo *models.ReportChapter) (err erro
 		BodyContent:        utils.TrimHtml(html.UnescapeString(chapterInfo.Content)),
 		PublishTime:        chapterInfo.PublishTime.Format(utils.FormatDateTime),
 		PublishState:       chapterInfo.PublishState,
+		IsPublicPublish:    isPublicPublish,
 		Author:             chapterInfo.Author,
 		ClassifyIdFirst:    chapterInfo.ClassifyIdFirst,
 		ClassifyNameFirst:  chapterInfo.ClassifyNameFirst,

+ 21 - 0
services/report_v2.go

@@ -144,6 +144,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 {
 	//	// 报告期数
@@ -278,6 +279,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
 }