|
@@ -4,10 +4,12 @@ import (
|
|
sql2 "database/sql"
|
|
sql2 "database/sql"
|
|
"errors"
|
|
"errors"
|
|
"eta/eta_api/global"
|
|
"eta/eta_api/global"
|
|
|
|
+ "eta/eta_api/models/report"
|
|
"eta/eta_api/utils"
|
|
"eta/eta_api/utils"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm"
|
|
|
|
+ "gorm.io/gorm/clause"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
@@ -90,6 +92,7 @@ type Report struct {
|
|
ReportCreateTime time.Time `description:"报告时间创建时间"`
|
|
ReportCreateTime time.Time `description:"报告时间创建时间"`
|
|
InheritReportId int `description:"待继承的报告ID"`
|
|
InheritReportId int `description:"待继承的报告ID"`
|
|
VoiceGenerateType int `description:"音频生成方式,0:系统生成,1:人工上传"`
|
|
VoiceGenerateType int `description:"音频生成方式,0:系统生成,1:人工上传"`
|
|
|
|
+ FreeLayoutConfig string `description:"'自由布局配置"`
|
|
}
|
|
}
|
|
|
|
|
|
func (m *Report) AfterFind(db *gorm.DB) (err error) {
|
|
func (m *Report) AfterFind(db *gorm.DB) (err error) {
|
|
@@ -612,7 +615,7 @@ type AddReq struct {
|
|
HeadResourceId int `description:"版头资源ID"`
|
|
HeadResourceId int `description:"版头资源ID"`
|
|
EndResourceId int `description:"版尾资源ID"`
|
|
EndResourceId int `description:"版尾资源ID"`
|
|
CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
|
|
CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
|
|
- ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
|
|
+ ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局,3:自由布局。默认:1"`
|
|
IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
|
|
IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
|
|
InheritReportId int `description:"待继承的报告ID"`
|
|
InheritReportId int `description:"待继承的报告ID"`
|
|
GrantAdminIdList []int `description:"授权用户id列表"`
|
|
GrantAdminIdList []int `description:"授权用户id列表"`
|
|
@@ -641,29 +644,30 @@ func AddReport(item *Report) (lastId int64, err error) {
|
|
}
|
|
}
|
|
|
|
|
|
type EditReq struct {
|
|
type EditReq struct {
|
|
- ReportId int64 `description:"报告id"`
|
|
+ ReportId int64 `description:"报告id"`
|
|
- ClassifyIdFirst int `description:"一级分类id"`
|
|
+ ClassifyIdFirst int `description:"一级分类id"`
|
|
- ClassifyNameFirst string `description:"一级分类名称"`
|
|
+ ClassifyNameFirst string `description:"一级分类名称"`
|
|
- ClassifyIdSecond int `description:"二级分类id"`
|
|
+ ClassifyIdSecond int `description:"二级分类id"`
|
|
- ClassifyNameSecond string `description:"二级分类名称"`
|
|
+ ClassifyNameSecond string `description:"二级分类名称"`
|
|
- ClassifyIdThird int `description:"三级分类id"`
|
|
+ ClassifyIdThird int `description:"三级分类id"`
|
|
- ClassifyNameThird string `description:"三级分类名称"`
|
|
+ ClassifyNameThird string `description:"三级分类名称"`
|
|
- Title string `description:"标题"`
|
|
+ Title string `description:"标题"`
|
|
- Abstract string `description:"摘要"`
|
|
+ Abstract string `description:"摘要"`
|
|
- Author string `description:"作者"`
|
|
+ Author string `description:"作者"`
|
|
- Frequency string `description:"频度"`
|
|
+ Frequency string `description:"频度"`
|
|
- State int `description:"状态:1:未发布,2:已发布"`
|
|
+ State int `description:"状态:1:未发布,2:已发布"`
|
|
- Content string `description:"内容"`
|
|
+ Content string `description:"内容"`
|
|
- CreateTime string `description:"创建时间"`
|
|
+ FreeLayoutContentPages []report.ContentPage `description:"自由布局页面列表"`
|
|
- ContentStruct string `description:"内容组件"`
|
|
+ CreateTime string `description:"创建时间"`
|
|
- HeadImg string `description:"报告头图地址"`
|
|
+ ContentStruct string `description:"内容组件"`
|
|
- EndImg string `description:"报告尾图地址"`
|
|
+ HeadImg string `description:"报告头图地址"`
|
|
- CanvasColor string `description:"画布颜色"`
|
|
+ EndImg string `description:"报告尾图地址"`
|
|
- NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
|
|
+ CanvasColor string `description:"画布颜色"`
|
|
- HeadResourceId int `description:"版头资源ID"`
|
|
+ NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
|
|
- EndResourceId int `description:"版尾资源ID"`
|
|
+ HeadResourceId int `description:"版头资源ID"`
|
|
|
|
+ EndResourceId int `description:"版尾资源ID"`
|
|
|
|
|
|
-
|
|
+
|
|
IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
|
|
IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
|
|
GrantAdminIdList []int `description:"授权用户id列表"`
|
|
GrantAdminIdList []int `description:"授权用户id列表"`
|
|
}
|
|
}
|
|
@@ -812,7 +816,6 @@ type SaveReportContent struct {
|
|
Content string `description:"内容"`
|
|
Content string `description:"内容"`
|
|
ReportId int `description:"报告id"`
|
|
ReportId int `description:"报告id"`
|
|
NoChange int `description:"内容是否未改变:1:内容未改变"`
|
|
NoChange int `description:"内容是否未改变:1:内容未改变"`
|
|
-
|
|
|
|
|
|
|
|
ContentStruct string `description:"内容组件"`
|
|
ContentStruct string `description:"内容组件"`
|
|
HeadImg string `description:"报告头图地址"`
|
|
HeadImg string `description:"报告头图地址"`
|
|
@@ -821,6 +824,9 @@ type SaveReportContent struct {
|
|
NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
|
|
NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
|
|
HeadResourceId int `description:"版头资源ID"`
|
|
HeadResourceId int `description:"版头资源ID"`
|
|
EndResourceId int `description:"版尾资源ID"`
|
|
EndResourceId int `description:"版尾资源ID"`
|
|
|
|
+
|
|
|
|
+ FreeLayoutContentPages []report.ContentPage `description:"自由布局页面数据"`
|
|
|
|
+ FreeLayoutConfig string `description:"自由布局配置"`
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1689,3 +1695,77 @@ type ReportShartUrlReq struct {
|
|
type ReportShartUrlResp struct {
|
|
type ReportShartUrlResp struct {
|
|
UrlToken string `description:"分享链接token"`
|
|
UrlToken string `description:"分享链接token"`
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func InsertOrUpdateReportFreeLayoutContentPage(report *Report, ormList []*report.ReportFreeLayout) (err error) {
|
|
|
|
+ tx := global.DbMap[utils.DbNameReport].Begin()
|
|
|
|
+
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+ _ = tx.Rollback()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ _ = tx.Commit()
|
|
|
|
+ }()
|
|
|
|
+ reportUpdateCols := []string{"Content", "ContentSub", "ContentStruct", "HeadImg", "EndImg", "CanvasColor", "HeadResourceId", "EndResourceId", "ModifyTime", "ContentModifyTime"}
|
|
|
|
+ err = tx.Model(&report).Select(reportUpdateCols).Updates(report).Error
|
|
|
|
+
|
|
|
|
+ tx.Clauses(clause.OnConflict{
|
|
|
|
+ Columns: []clause.Column{{Name: "report_id"}, {Name: "report_chapter_id"}, {Name: "page"}},
|
|
|
|
+ DoUpdates: clause.AssignmentColumns([]string{"content", "content_struct", "modify_time", "is_deleted"}),
|
|
|
|
+ })
|
|
|
|
+ err = tx.Where("report_id = ?", report.Id).Update("is_deleted", 1).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ err = tx.CreateInBatches(ormList, len(ormList)).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+func UpdateChapterFreeLayoutContentPage(reportInfo *Report, chapterInfo *ReportChapter, updateCols []string, tickerList []*ReportChapterTicker, ormList []*report.ReportFreeLayout) (err error) {
|
|
|
|
+ tx := global.DbMap[utils.DbNameReport].Begin()
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+ _ = tx.Rollback()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ _ = tx.Commit()
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ if err = tx.Model(&reportInfo).Select([]string{"LastModifyAdminId", "LastModifyAdminName", "ModifyTime"}).Updates(reportInfo).Error; err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if err = tx.Model(&chapterInfo).Select(updateCols).Updates(chapterInfo).Error; err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ sql := ` DELETE FROM report_chapter_ticker WHERE report_chapter_id = ? `
|
|
|
|
+
|
|
|
|
+ if err = tx.Exec(sql, chapterInfo.ReportChapterId).Error; err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ tickerLen := len(tickerList)
|
|
|
|
+ if tickerLen > 0 {
|
|
|
|
+ err = tx.CreateInBatches(tickerList, len(tickerList)).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ tx.Clauses(clause.OnConflict{
|
|
|
|
+ Columns: []clause.Column{{Name: "report_id"}, {Name: "report_chapter_id"}, {Name: "page"}},
|
|
|
|
+ DoUpdates: clause.AssignmentColumns([]string{"content", "content_struct", "modify_time", "is_deleted"}),
|
|
|
|
+ })
|
|
|
|
+ err = tx.Where("report_id = ? and report_chapter_id=? and is_chapter=1", reportInfo.Id, chapterInfo.ReportChapterId).Update("is_deleted", 1).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ err = tx.CreateInBatches(ormList, len(ormList)).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ reportUpdateCols := []string{"Content", "ContentSub", "ContentStruct", "HeadImg", "EndImg", "CanvasColor", "HeadResourceId", "EndResourceId", "ModifyTime", "ContentModifyTime"}
|
|
|
|
+ err = tx.Model(&reportInfo).Select(reportUpdateCols).Updates(reportInfo).Error
|
|
|
|
+ return
|
|
|
|
+}
|