Преглед на файлове

fix:报告在创建/编辑的时候就需要根据分类情况来做状态的调整

Roc преди 8 месеца
родител
ревизия
bec097e909
променени са 4 файла, в които са добавени 88 реда и са изтрити 22 реда
  1. 12 17
      controllers/report_chapter.go
  2. 55 3
      models/report_chapter.go
  3. 1 1
      services/report.go
  4. 20 1
      services/report_v2.go

+ 12 - 17
controllers/report_chapter.go

@@ -713,20 +713,15 @@ func (this *ReportController) GetDayWeekChapter() {
 		return
 	}
 
-	chapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
+	chapterItem, err := models.GetReportChapterItemById(reportChapterId)
 	if err != nil {
 		br.Msg = "获取章节信息失败"
 		br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
 		return
 	}
-	if chapterInfo != nil {
-		chapterInfo.Content = html.UnescapeString(chapterInfo.Content)
-		chapterInfo.ContentSub = html.UnescapeString(chapterInfo.ContentSub)
-		chapterInfo.ContentStruct = html.UnescapeString(chapterInfo.ContentStruct)
-	}
 
 	// 获取报告详情
-	reportInfo, err := models.GetReportById(chapterInfo.ReportId)
+	reportInfo, err := models.GetReportById(chapterItem.ReportId)
 	if err != nil {
 		br.Msg = "获取报告信息失败"
 		br.ErrMsg = "获取报告信息失败, Err: " + err.Error()
@@ -746,9 +741,9 @@ func (this *ReportController) GetDayWeekChapter() {
 		return
 	}
 
-	chapterInfo.Content = html.UnescapeString(chapterInfo.Content)
-	chapterInfo.ContentSub = html.UnescapeString(chapterInfo.ContentSub)
-	chapterInfo.ContentStruct = html.UnescapeString(chapterInfo.ContentStruct)
+	chapterItem.Content = html.UnescapeString(chapterItem.Content)
+	chapterItem.ContentSub = html.UnescapeString(chapterItem.ContentSub)
+	chapterItem.ContentStruct = html.UnescapeString(chapterItem.ContentStruct)
 
 	// 授权用户列表map
 	chapterGrantIdList := make([]int, 0)
@@ -757,7 +752,7 @@ func (this *ReportController) GetDayWeekChapter() {
 	// 处理章节id授权用户列表
 	{
 		chapterGrantObj := report.ReportChapterGrant{}
-		chapterGrantList, tmpErr := chapterGrantObj.GetGrantListById(chapterInfo.ReportChapterId)
+		chapterGrantList, tmpErr := chapterGrantObj.GetGrantListById(chapterItem.ReportChapterId)
 		if tmpErr != nil {
 			br.Msg = "获取章节id授权用户列表失败"
 			br.ErrMsg = "获取章节id授权用户列表失败, Err: " + tmpErr.Error()
@@ -772,7 +767,7 @@ func (this *ReportController) GetDayWeekChapter() {
 	// 处理章节id关联品种id列表
 	{
 		obj := report.ReportChapterPermissionMapping{}
-		chapterPermissionList, tmpErr := obj.GetPermissionListById(chapterInfo.ReportChapterId)
+		chapterPermissionList, tmpErr := obj.GetPermissionListById(chapterItem.ReportChapterId)
 		if tmpErr != nil {
 			br.Msg = "获取章节id关联品种列表失败"
 			br.ErrMsg = "获取章节id关联品种列表失败, Err: " + tmpErr.Error()
@@ -784,15 +779,15 @@ func (this *ReportController) GetDayWeekChapter() {
 		}
 	}
 
-	resp := models.ReportChapterItem{
-		ReportChapter:    *chapterInfo,
-		GrandAdminIdList: chapterGrantIdList,
-		PermissionIdList: chapterPermissionIdList,
+	resp := models.ReportChapterItemResp{
+		ReportChapterItem: *chapterItem,
+		GrandAdminIdList:  chapterGrantIdList,
+		PermissionIdList:  chapterPermissionIdList,
 	}
 
 	// 获取当前编辑状态
 	{
-		markStatus, err := services.UpdateReportEditMark(chapterInfo.ReportId, chapterInfo.ReportChapterId, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
+		markStatus, err := services.UpdateReportEditMark(chapterItem.ReportId, chapterItem.ReportChapterId, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
 		if err != nil {
 			br.Msg = "查询标记状态失败"
 			br.ErrMsg = "查询标记状态失败,Err:" + err.Error()

+ 55 - 3
models/report_chapter.go

@@ -44,10 +44,47 @@ type ReportChapter struct {
 	ReportCreateTime    time.Time `description:"报告时间创建时间"`
 }
 
-// ReportChapterItem
-// @Description: 章节详情(带有一些额外的数据)
+// ReportChapterItem 报告章节详情
 type ReportChapterItem struct {
-	ReportChapter
+	ReportChapterId     int    `orm:"column(report_chapter_id);pk" description:"报告章节ID"`
+	ReportId            int    `description:"报告ID"`
+	ReportType          string `description:"报告类型 day-晨报 week-周报"`
+	ClassifyIdFirst     int    `description:"一级分类id"`
+	ClassifyNameFirst   string `description:"一级分类名称"`
+	TypeId              int    `description:"品种ID"`
+	TypeName            string `description:"品种名称"`
+	Title               string `description:"标题"`
+	Abstract            string `description:"摘要"`
+	AddType             int    `description:"新增方式:1:新增报告,2:继承报告"`
+	Author              string `description:"作者"`
+	Content             string `description:"内容"`
+	ContentSub          string `description:"内容前两个章节"`
+	Stage               int    `description:"期数"`
+	Trend               string `description:"趋势观点"`
+	Sort                int    `description:"排序: 数值越小越靠前"`
+	IsEdit              int    `description:"是否已编辑 0-待编辑 1-已编辑"`
+	PublishState        int    `description:"发布状态 1-待发布,2-已发布"`
+	PublishTime         string `description:"发布时间"`
+	VideoUrl            string `description:"音频文件URL"`
+	VideoName           string `description:"音频文件名称"`
+	VideoPlaySeconds    string `description:"音频播放时长"`
+	VideoSize           string `description:"音频文件大小,单位M"`
+	VideoKind           int    `description:"音频生成方式:1,手动上传,2:自动生成"`
+	CreateTime          string `description:"创建时间"`
+	ModifyTime          string `description:"修改时间"`
+	OriginalVideoUrl    string `description:"原始音频文件URL"`
+	ContentStruct       string `description:"内容组件"`
+	LastModifyAdminId   int    `description:"最后更新人ID"`
+	LastModifyAdminName string `description:"最后更新人姓名"`
+	ContentModifyTime   string `description:"内容更新时间"`
+	ReportLayout        int8   `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
+	ReportCreateTime    string `description:"报告时间创建时间"`
+}
+
+// ReportChapterItemResp
+// @Description: 章节详情(带有一些额外的数据)
+type ReportChapterItemResp struct {
+	ReportChapterItem
 	GrandAdminIdList []int  `description:"授权的用户id列表"`
 	PermissionIdList []int  `description:"关联的品种id列表"`
 	CanEdit          bool   `description:"是否可编辑"`
@@ -155,6 +192,21 @@ func GetReportChapterInfoById(reportChapterId int) (item *ReportChapter, err err
 	return
 }
 
+// GetReportChapterItemById
+// @Description: 根据主键获取报告章节(时间格式为字符串的数据)
+// @author: Roc
+// @datetime 2024-06-27 14:10:29
+// @param reportChapterId int
+// @return item *ReportChapterItem
+// @return err error
+func GetReportChapterItemById(reportChapterId int) (item *ReportChapterItem, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ? `
+	err = o.Raw(sql, reportChapterId).QueryRow(&item)
+
+	return
+}
+
 // GetLastPublishedReportChapter 获取上一篇已发表的晨周报章节
 func GetLastPublishedReportChapter(typeId int, reportType string) (item *ReportChapter, err error) {
 	o := orm.NewOrmUsingDB("rddp")

+ 1 - 1
services/report.go

@@ -122,7 +122,7 @@ func PublishDayWeekReport(reportInfo *models.Report) (tips string, err error, er
 	//	title = firstTitle
 	//}
 	//report.Title = title
-	reportInfo.State = models.ReportStatePublished
+	reportInfo.State = state
 
 	// 研报后台4.4 只在没有发布过时更新发布时间,其余均按模版消息发送时间当作发布时间
 	if reportInfo.MsgIsSend == 0 || reportInfo.PublishTime.IsZero() {

+ 20 - 1
services/report_v2.go

@@ -26,6 +26,16 @@ import (
 // @return err error
 // @return errMsg string
 func AddReportAndChapter(reportInfo *models.Report, inheritReportId int, grantAdminIdList []int) (err error, errMsg string) {
+	// 根据审批开关及审批流判断当前报告状态
+	state, e := CheckReportCurrState(report_approve.FlowReportTypeChinese, reportInfo.ClassifyIdFirst, reportInfo.ClassifyIdSecond, reportInfo.ClassifyIdThird, models.ReportOperateAdd)
+	if e != nil {
+		//errMsg = "操作失败"
+		err = errors.New("校验报告当前状态失败, Err: " + e.Error())
+		return
+	}
+	// 报告状态
+	reportInfo.State = state
+
 	// 获取最小分类id
 	minClassifyId := reportInfo.ClassifyIdThird
 	if minClassifyId <= 0 {
@@ -157,8 +167,17 @@ func EditReport(reportInfo *models.Report, req models.EditReq, sysUser *system.A
 	reportInfo.LastModifyAdminName = sysUser.RealName
 	reportInfo.ModifyTime = time.Now()
 
+	state, e := CheckReportCurrState(report_approve.FlowReportTypeChinese, reportInfo.ClassifyIdFirst, reportInfo.ClassifyIdSecond, reportInfo.ClassifyIdThird, models.ReportOperateEdit)
+	if e != nil {
+		//errMsg = "操作失败"
+		err = errors.New("校验报告当前状态失败, Err: " + e.Error())
+		return
+	}
+	// 报告状态
+	reportInfo.State = state
+
 	//updateCols := []string{"ClassifyIdFirst", "ClassifyNameFirst", "ClassifyIdSecond", "ClassifyNameSecond", "ClassifyIdThird", "ClassifyNameThird", "Title", "Abstract", "Author", "Frequency", "Stage", "CreateTime", "IsPublicPublish", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime"}
-	updateCols := []string{"Title", "Abstract", "Author", "Frequency", "CreateTime", "IsPublicPublish", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime"}
+	updateCols := []string{"Title", "Abstract", "Author", "Frequency", "CreateTime", "IsPublicPublish", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime", "State"}
 
 	if req.HeadResourceId > 0 {
 		reportInfo.HeadResourceId = req.HeadResourceId