|
@@ -12,13 +12,13 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-func (this *ReportController) AddDayWeekChapter() {
|
|
|
+
|
|
|
+func (this *ReportController) AddChapter() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
@@ -47,46 +47,46 @@ func (this *ReportController) AddDayWeekChapter() {
|
|
|
}
|
|
|
|
|
|
|
|
|
- reportInfo, err := models.GetReportById(req.ReportId)
|
|
|
+ reportInfo, err := models.GetReportByReportId(req.ReportId)
|
|
|
if err != nil {
|
|
|
br.Msg = "报告信息有误"
|
|
|
br.ErrMsg = "报告信息有误, Err: " + err.Error()
|
|
|
return
|
|
|
}
|
|
|
if reportInfo.State == 2 {
|
|
|
- br.Msg = "该报告已发布,不允许编辑"
|
|
|
- br.ErrMsg = "该报告已发布,不允许编辑"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- newContent := req.Content
|
|
|
-
|
|
|
- contentSub := ""
|
|
|
- if req.Content != "" {
|
|
|
- e := utils.ContentXssCheck(req.Content)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "存在非法标签"
|
|
|
- br.ErrMsg = "存在非法标签, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- contentClean, e := services.FilterReportContentBr(req.Content)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "内容去除前后空格失败"
|
|
|
- br.ErrMsg = "内容去除前后空格失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- req.Content = contentClean
|
|
|
-
|
|
|
- contentSub, err = services.GetReportContentSub(req.Content)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "内容分段解析失败"
|
|
|
- br.ErrMsg = "编辑报告章节-解析 ContentSub 失败, Err: " + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- if req.Content == "" {
|
|
|
- req.Content = newContent
|
|
|
- }
|
|
|
+ br.Msg = "该报告已发布,不允许新增"
|
|
|
+ br.ErrMsg = "该报告已发布,不允许新增"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
reportChapterInfo := new(models.ReportChapter)
|
|
|
reportChapterInfo.ReportId = reportInfo.Id
|
|
@@ -95,11 +95,12 @@ func (this *ReportController) AddDayWeekChapter() {
|
|
|
|
|
|
reportChapterInfo.Title = req.Title
|
|
|
reportChapterInfo.AddType = 1
|
|
|
- reportChapterInfo.Author = req.Author
|
|
|
- reportChapterInfo.Content = html.EscapeString(req.Content)
|
|
|
- reportChapterInfo.ContentSub = html.EscapeString(contentSub)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
reportChapterInfo.IsEdit = 1
|
|
|
- reportChapterInfo.CreateTime = req.CreateTime
|
|
|
+
|
|
|
+ reportChapterInfo.CreateTime = reportInfo.CreateTime
|
|
|
reportChapterInfo.VideoKind = 1
|
|
|
|
|
|
reportChapterInfo.ClassifyIdSecond = reportInfo.ClassifyIdSecond
|
|
@@ -109,23 +110,21 @@ func (this *ReportController) AddDayWeekChapter() {
|
|
|
reportChapterInfo.LastModifyAdminId = sysUser.AdminId
|
|
|
reportChapterInfo.LastModifyAdminName = sysUser.RealName
|
|
|
reportChapterInfo.ContentModifyTime = time.Now()
|
|
|
- reportChapterInfo.ContentStruct = html.EscapeString(req.ContentStruct)
|
|
|
- reportChapterInfo.CanvasColor = req.CanvasColor
|
|
|
- reportChapterInfo.HeadResourceId = req.HeadResourceId
|
|
|
- reportChapterInfo.EndResourceId = req.EndResourceId
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- err = reportChapterInfo.Add()
|
|
|
+ err, errMsg := services.AddChapterBaseInfoAndPermission(reportInfo, reportChapterInfo, req.PermissionIdList, req.AdminIdList)
|
|
|
if err != nil {
|
|
|
- br.Msg = "新增失败"
|
|
|
- br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ if errMsg != "" {
|
|
|
+ br.Msg = errMsg
|
|
|
+ }
|
|
|
+ br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- chapters := make([]*models.ReportChapter, 0)
|
|
|
- chapters = append(chapters, reportChapterInfo)
|
|
|
- go services.SaveReportLogs(nil, chapters, sysUser.AdminId, sysUser.RealName)
|
|
|
-
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "保存成功"
|
|
@@ -736,6 +735,10 @@ func (this *ReportController) GetDayWeekChapter() {
|
|
|
chapterInfo.ContentStruct = html.UnescapeString(chapterInfo.ContentStruct)
|
|
|
}
|
|
|
|
|
|
+ chapterInfo.Content = html.UnescapeString(chapterInfo.Content)
|
|
|
+ chapterInfo.ContentSub = html.UnescapeString(chapterInfo.ContentSub)
|
|
|
+ chapterInfo.ContentStruct = html.UnescapeString(chapterInfo.ContentStruct)
|
|
|
+
|
|
|
|
|
|
chapterGrantIdList := make([]int, 0)
|
|
|
|