|
@@ -372,6 +372,12 @@ func (this *ReportController) EditDayWeekChapter() {
|
|
|
br.ErrMsg = "该报告已发布,不允许编辑"
|
|
|
return
|
|
|
}
|
|
|
+ if reportChapterInfo.PublishState == 2 {
|
|
|
+ br.Msg = "该报告章节已发布,不允许编辑"
|
|
|
+ br.ErrMsg = "该报告章节已发布,不允许编辑"
|
|
|
+ br.IsSendEmail = false
|
|
|
+ return
|
|
|
+ }
|
|
|
// 报告的最后编辑人
|
|
|
reportInfo.LastModifyAdminId = sysUser.AdminId
|
|
|
reportInfo.LastModifyAdminName = sysUser.RealName
|
|
@@ -1616,3 +1622,90 @@ func (this *ReportController) EditChapterTitle() {
|
|
|
br.Success = true
|
|
|
br.Msg = "保存成功"
|
|
|
}
|
|
|
+
|
|
|
+// CancelPublishReportChapter
|
|
|
+// @Title 取消发布章节
|
|
|
+// @Description 取消发布章节
|
|
|
+// @Param request body models.PublishReportChapterReq true "type json string"
|
|
|
+// @Success 200 Ret=200 操作成功
|
|
|
+// @router /chapter/publish/cancel [post]
|
|
|
+func (this *ReportController) CancelPublishReportChapter() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var req models.PublishReportChapterReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.ReportChapterId <= 0 {
|
|
|
+ br.Msg = "参数有误"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取章节详情
|
|
|
+ chapterInfo, err := models.GetReportChapterInfoById(req.ReportChapterId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "章节信息有误"
|
|
|
+ br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 章节发布状态校验
|
|
|
+ if chapterInfo.PublishState == 1 {
|
|
|
+ br.Msg = "该章节未发布,不能重复撤销"
|
|
|
+ br.ErrMsg = "该章节未发布,不能重复撤销"
|
|
|
+ br.IsSendEmail = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取报告详情
|
|
|
+ reportInfo, err := models.GetReportByReportId(chapterInfo.ReportId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询报告有误"
|
|
|
+ br.ErrMsg = "查询报告信息失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if reportInfo.State == 2 {
|
|
|
+ br.Msg = "该报告已发布,不允许撤销章节"
|
|
|
+ br.ErrMsg = "该报告已发布,不允许撤销章节"
|
|
|
+ br.IsSendEmail = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新章节信息
|
|
|
+ chapterInfo.PublishState = 1
|
|
|
+ chapterInfo.PublishTime = time.Time{}
|
|
|
+ chapterInfo.LastModifyAdminId = this.SysUser.AdminId
|
|
|
+ chapterInfo.LastModifyAdminName = this.SysUser.RealName
|
|
|
+ chapterInfo.ModifyTime = time.Now()
|
|
|
+
|
|
|
+ updateCols := make([]string, 0)
|
|
|
+ updateCols = append(updateCols, "PublishState", "PublishTime", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime")
|
|
|
+ err = chapterInfo.UpdateChapter(updateCols)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "发布失败"
|
|
|
+ br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新章节ES
|
|
|
+ {
|
|
|
+ go services.UpdateReportChapterEs(chapterInfo.ReportChapterId)
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "撤销成功"
|
|
|
+}
|