|
@@ -9,7 +9,6 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"gorm.io/gorm"
|
|
|
- "gorm.io/gorm/clause"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
@@ -956,9 +955,10 @@ func (reportInfo *Report) UpdateReport(cols []string) (err error) {
|
|
|
// @Description: 晨周报详情
|
|
|
type ReportDetailView struct {
|
|
|
*ReportDetail
|
|
|
- ChapterList []*ReportChapter
|
|
|
- GrandAdminList []ReportDetailViewAdmin
|
|
|
- PermissionList []ReportDetailViewPermission
|
|
|
+ ChapterList []*ReportChapter
|
|
|
+ GrandAdminList []ReportDetailViewAdmin
|
|
|
+ PermissionList []ReportDetailViewPermission
|
|
|
+ FreeLayoutContentPages []*report.ContentPage
|
|
|
}
|
|
|
|
|
|
// ReportDetailViewAdmin
|
|
@@ -1696,7 +1696,7 @@ type ReportShartUrlResp struct {
|
|
|
UrlToken string `description:"分享链接token"`
|
|
|
}
|
|
|
|
|
|
-func InsertOrUpdateReportFreeLayoutContentPage(report *Report, ormList []*report.ReportFreeLayout) (err error) {
|
|
|
+func InsertOrUpdateReportFreeLayoutContentPage(reportInfo *Report, ormList []*report.ReportFreeLayout) (err error) {
|
|
|
tx := global.DbMap[utils.DbNameReport].Begin()
|
|
|
|
|
|
defer func() {
|
|
@@ -1707,22 +1707,8 @@ func InsertOrUpdateReportFreeLayoutContentPage(report *Report, ormList []*report
|
|
|
_ = 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
|
|
|
+ err = tx.Model(&reportInfo).Select(reportUpdateCols).Updates(reportInfo).Error
|
|
|
+ return report.BatchInsertOrUpdatePages(tx, ormList, false, reportInfo.Id, 0)
|
|
|
}
|
|
|
func UpdateChapterFreeLayoutContentPage(reportInfo *Report, chapterInfo *ReportChapter, updateCols []string, tickerList []*ReportChapterTicker, ormList []*report.ReportFreeLayout) (err error) {
|
|
|
tx := global.DbMap[utils.DbNameReport].Begin()
|
|
@@ -1753,19 +1739,5 @@ func UpdateChapterFreeLayoutContentPage(reportInfo *Report, chapterInfo *ReportC
|
|
|
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
|
|
|
+ return report.BatchInsertOrUpdatePages(tx, ormList, true, reportInfo.Id, chapterInfo.ReportChapterId)
|
|
|
}
|