|
@@ -3,6 +3,7 @@ package controllers
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"eta/eta_api/models"
|
|
|
+ "eta/eta_api/models/report"
|
|
|
"eta/eta_api/models/report_approve"
|
|
|
"eta/eta_api/services"
|
|
|
"eta/eta_api/services/alarm_msg"
|
|
@@ -15,6 +16,8 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
+// TODO 报告的权限校验(跳过列表页,直接进入详情页,不管是普通报告还是章节报告)
|
|
|
+
|
|
|
// ListReport
|
|
|
// @Title 获取报告列表接口
|
|
|
// @Description 获取报告列表
|
|
@@ -260,20 +263,20 @@ func (this *ReportController) ListReport() {
|
|
|
}
|
|
|
item.Editor = adminInfo.RealName
|
|
|
}*/
|
|
|
- if item.ClassifyNameFirst == "周报" || item.ClassifyNameFirst == "晨报" {
|
|
|
+ if item.HasChapter == 1 {
|
|
|
+ item.CanEdit = true
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ markStatus, err := services.UpdateReportEditMark(item.Id, 0, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询标记状态失败"
|
|
|
+ br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if markStatus.Status == 0 {
|
|
|
item.CanEdit = true
|
|
|
} else {
|
|
|
- markStatus, err := services.UpdateReportEditMark(item.Id, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "查询标记状态失败"
|
|
|
- br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if markStatus.Status == 0 {
|
|
|
- item.CanEdit = true
|
|
|
- } else {
|
|
|
- item.Editor = markStatus.Editor
|
|
|
- }
|
|
|
+ item.Editor = markStatus.Editor
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -472,7 +475,7 @@ func (this *ReportController) Edit() {
|
|
|
}
|
|
|
|
|
|
//更新标记key
|
|
|
- markStatus, err := services.UpdateReportEditMark(int(req.ReportId), sysUser.AdminId, 1, sysUser.RealName, this.Lang)
|
|
|
+ markStatus, err := services.UpdateReportEditMark(int(req.ReportId), 0, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
|
|
|
if err != nil {
|
|
|
br.Msg = err.Error()
|
|
|
return
|
|
@@ -484,7 +487,7 @@ func (this *ReportController) Edit() {
|
|
|
}
|
|
|
|
|
|
var stage int
|
|
|
- report, e := models.GetReportByReportId(int(req.ReportId))
|
|
|
+ reportInfo, e := models.GetReportByReportId(int(req.ReportId))
|
|
|
if e != nil {
|
|
|
if e.Error() == utils.ErrNoRow() {
|
|
|
br.Msg = "报告已被删除, 请刷新页面"
|
|
@@ -494,20 +497,20 @@ func (this *ReportController) Edit() {
|
|
|
br.ErrMsg = "获取报告失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
- if report.State == models.ReportStatePublished || report.State == models.ReportStatePass {
|
|
|
+ if reportInfo.State == models.ReportStatePublished || reportInfo.State == models.ReportStatePass {
|
|
|
br.Msg = "该报告已发布,不允许编辑"
|
|
|
br.ErrMsg = "该报告已发布,不允许编辑"
|
|
|
return
|
|
|
}
|
|
|
- if report.ClassifyNameFirst != req.ClassifyNameFirst || report.ClassifyNameSecond != req.ClassifyNameSecond {
|
|
|
+ if reportInfo.ClassifyNameFirst != req.ClassifyNameFirst || reportInfo.ClassifyNameSecond != req.ClassifyNameSecond {
|
|
|
// 报告期数
|
|
|
maxStage, _ := models.GetReportStageEdit(req.ClassifyIdFirst, req.ClassifyIdSecond, req.ClassifyIdThird, int(req.ReportId))
|
|
|
maxStage = maxStage + 1
|
|
|
stage = maxStage
|
|
|
} else {
|
|
|
- stage = report.Stage
|
|
|
+ stage = reportInfo.Stage
|
|
|
}
|
|
|
- //if req.State != report.State {
|
|
|
+ //if req.State != reportInfo.State {
|
|
|
// recordItem := &models.ReportStateRecord{
|
|
|
// ReportId: int(req.ReportId),
|
|
|
// ReportType: 1,
|
|
@@ -522,28 +525,28 @@ func (this *ReportController) Edit() {
|
|
|
//}
|
|
|
|
|
|
//item := new(models.Report)
|
|
|
- report.ClassifyIdFirst = req.ClassifyIdFirst
|
|
|
- report.ClassifyNameFirst = req.ClassifyNameFirst
|
|
|
- report.ClassifyIdSecond = req.ClassifyIdSecond
|
|
|
- report.ClassifyNameSecond = req.ClassifyNameSecond
|
|
|
- report.ClassifyIdThird = req.ClassifyIdThird
|
|
|
- report.ClassifyNameThird = req.ClassifyNameThird
|
|
|
- report.Title = req.Title
|
|
|
- report.Abstract = req.Abstract
|
|
|
- report.Author = req.Author
|
|
|
- report.Frequency = req.Frequency
|
|
|
- //report.State = report.State // 编辑不变更状态
|
|
|
- report.Stage = stage // 编辑不变更期数
|
|
|
- //report.Content = html.EscapeString(req.Content) // 编辑不变更具体内容
|
|
|
- //report.ContentSub = html.EscapeString(contentSub) // 编辑不变更具体内容
|
|
|
- report.CreateTime = req.CreateTime
|
|
|
- //report.CollaborateType = req.CollaborateType
|
|
|
- //report.ReportLayout = req.ReportLayout
|
|
|
+ reportInfo.ClassifyIdFirst = req.ClassifyIdFirst
|
|
|
+ reportInfo.ClassifyNameFirst = req.ClassifyNameFirst
|
|
|
+ reportInfo.ClassifyIdSecond = req.ClassifyIdSecond
|
|
|
+ reportInfo.ClassifyNameSecond = req.ClassifyNameSecond
|
|
|
+ reportInfo.ClassifyIdThird = req.ClassifyIdThird
|
|
|
+ reportInfo.ClassifyNameThird = req.ClassifyNameThird
|
|
|
+ reportInfo.Title = req.Title
|
|
|
+ reportInfo.Abstract = req.Abstract
|
|
|
+ reportInfo.Author = req.Author
|
|
|
+ reportInfo.Frequency = req.Frequency
|
|
|
+ //reportInfo.State = reportInfo.State // 编辑不变更状态
|
|
|
+ reportInfo.Stage = stage // 编辑不变更期数
|
|
|
+ //reportInfo.Content = html.EscapeString(req.Content) // 编辑不变更具体内容
|
|
|
+ //reportInfo.ContentSub = html.EscapeString(contentSub) // 编辑不变更具体内容
|
|
|
+ reportInfo.CreateTime = req.CreateTime
|
|
|
+ //reportInfo.CollaborateType = req.CollaborateType
|
|
|
+ //reportInfo.ReportLayout = req.ReportLayout
|
|
|
if req.IsPublicPublish <= 0 {
|
|
|
req.IsPublicPublish = 1
|
|
|
}
|
|
|
- report.IsPublicPublish = req.IsPublicPublish
|
|
|
- err = report.Update([]string{"ClassifyIdFirst", "ClassifyNameFirst", "ClassifyIdSecond", "ClassifyNameSecond", "ClassifyIdThird", "ClassifyNameThird", "Title", "Abstract", "Author", "Frequency", "Stage", "CreateTime", "IsPublicPublish"})
|
|
|
+ reportInfo.IsPublicPublish = req.IsPublicPublish
|
|
|
+ err = reportInfo.Update([]string{"ClassifyIdFirst", "ClassifyNameFirst", "ClassifyIdSecond", "ClassifyNameSecond", "ClassifyIdThird", "ClassifyNameThird", "Title", "Abstract", "Author", "Frequency", "Stage", "CreateTime", "IsPublicPublish"})
|
|
|
if err != nil {
|
|
|
br.Msg = "保存失败"
|
|
|
br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
@@ -751,7 +754,7 @@ func (this *ReportController) SaveReportContent() {
|
|
|
|
|
|
// 标记更新中
|
|
|
{
|
|
|
- markStatus, err := services.UpdateReportEditMark(int(req.ReportId), sysUser.AdminId, 1, sysUser.RealName, this.Lang)
|
|
|
+ markStatus, err := services.UpdateReportEditMark(int(req.ReportId), 0, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
|
|
|
if err != nil {
|
|
|
br.Msg = err.Error()
|
|
|
return
|
|
@@ -817,19 +820,18 @@ func (this *ReportController) SaveReportContent() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
-// GetReportChapterList
|
|
|
-// @Title 获取报告章节列表
|
|
|
-// @Description 获取报告章节列表
|
|
|
-// @Param ReportId query string true "报告ID"
|
|
|
-// @Success 200 {object} company.CompanyListResp
|
|
|
-// @router /getReportChapterList [get]
|
|
|
-func (this *ReportController) GetReportChapterList() {
|
|
|
+// PublishDayWeekReportChapter
|
|
|
+// @Title 发布晨周报章节
|
|
|
+// @Description 发布晨周报章节
|
|
|
+// @Param request body models.PublishReportChapterReq true "type json string"
|
|
|
+// @Success 200 Ret=200 操作成功
|
|
|
+// @router /publishDayWeekReportChapter [post]
|
|
|
+func (this *ReportController) PublishDayWeekReportChapter() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
sysUser := this.SysUser
|
|
|
if sysUser == nil {
|
|
|
br.Msg = "请登录"
|
|
@@ -838,141 +840,43 @@ func (this *ReportController) GetReportChapterList() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- reqReportId := this.GetString("ReportId")
|
|
|
- reportId, _ := strconv.Atoi(reqReportId)
|
|
|
- if reportId <= 0 {
|
|
|
- br.Msg = "报告ID有误"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 获取章节列表
|
|
|
- chapterList, err := models.GetChapterListByReportId(reportId)
|
|
|
+ var req models.PublishReportChapterReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取章节列表失败"
|
|
|
- br.ErrMsg = "获取章节列表失败, Err: " + err.Error()
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- typeList, err := models.GetReportChapterTypeList()
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取章节类型列表失败"
|
|
|
- br.ErrMsg = "获取章节类型列表失败, Err: " + err.Error()
|
|
|
+ if req.ReportChapterId <= 0 {
|
|
|
+ br.Msg = "参数有误"
|
|
|
return
|
|
|
}
|
|
|
- typeIdImg := make(map[int]string)
|
|
|
- for i := 0; i < len(typeList); i++ {
|
|
|
- typeIdImg[typeList[i].ReportChapterTypeId] = typeList[i].EditImgUrl
|
|
|
- }
|
|
|
-
|
|
|
- resp := make([]*models.ReportChapterResp, 0)
|
|
|
- if len(chapterList) > 0 {
|
|
|
- // 获取更新规则
|
|
|
- researchType := chapterList[0].ReportType
|
|
|
- chapterTypeList, tmpErr := models.GetAllReportChapterTypeListByResearchType(researchType)
|
|
|
- if tmpErr != nil {
|
|
|
- br.Msg = "获取更新规则失败"
|
|
|
- br.ErrMsg = "获取更新规则失败, Err: " + tmpErr.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- // 调整章节更新
|
|
|
- nowTime := time.Now().Local()
|
|
|
- for _, item := range chapterList {
|
|
|
- stop := false
|
|
|
- for _, rule := range chapterTypeList {
|
|
|
- if rule.ReportChapterTypeId == item.TypeId {
|
|
|
- //fmt.Println("rule.Enabled :", rule.Enabled, ";name=", rule.ReportChapterTypeName, "item.IsEdit:", item.IsEdit, "rule.IsSet:", rule.IsSet)
|
|
|
- // 如果被永久暂停更新了
|
|
|
- if rule.Enabled == 0 && item.IsEdit == 0 { //该章节已被永久禁用,同时未被操作过
|
|
|
- stop = true
|
|
|
- } else if rule.PauseStartTime != "" && rule.PauseEndTime != "" && rule.PauseStartTime != utils.EmptyDateStr && rule.PauseEndTime != utils.EmptyDateStr {
|
|
|
- startTime, timeErr := time.ParseInLocation(utils.FormatDate, rule.PauseStartTime, time.Local)
|
|
|
- if timeErr != nil {
|
|
|
- br.Msg = "获取更新规则失败"
|
|
|
- br.ErrMsg = "更新规则时间转换失败4001, Err: " + timeErr.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- endTime, timeErr := time.ParseInLocation(utils.FormatDate, rule.PauseEndTime, time.Local)
|
|
|
- if timeErr != nil {
|
|
|
- br.Msg = "获取更新规则失败"
|
|
|
- br.ErrMsg = "更新规则时间转换失败4002, Err: " + timeErr.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- // 暂停更新
|
|
|
- if nowTime.After(startTime) && nowTime.Before(endTime.AddDate(0, 0, 1)) {
|
|
|
- stop = true
|
|
|
- }
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if !stop {
|
|
|
- resp = append(resp, &models.ReportChapterResp{
|
|
|
- ReportChapterId: item.ReportChapterId,
|
|
|
- ReportId: item.ReportId,
|
|
|
- ReportType: item.ReportType,
|
|
|
- TypeId: item.TypeId,
|
|
|
- TypeName: item.TypeName,
|
|
|
- TypeEditImg: typeIdImg[item.TypeId],
|
|
|
- Title: item.Title,
|
|
|
- IsEdit: item.IsEdit,
|
|
|
- Trend: item.Trend,
|
|
|
- Sort: item.Sort,
|
|
|
- PublishState: item.PublishState,
|
|
|
- VideoUrl: item.VideoUrl,
|
|
|
- VideoName: item.VideoName,
|
|
|
- VideoPlaySeconds: item.VideoPlaySeconds,
|
|
|
- VideoSize: item.VideoSize,
|
|
|
- VideoKind: item.VideoKind,
|
|
|
- ModifyTime: item.ModifyTime.Format(utils.FormatDate),
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ if req.Title == "" {
|
|
|
+ br.Msg = "请输入标题"
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Msg = "获取成功"
|
|
|
- br.Data = resp
|
|
|
-}
|
|
|
-
|
|
|
-// EditDayWeekChapter
|
|
|
-// @Title 编辑晨周报章节内容
|
|
|
-// @Description 编辑晨周报章节内容
|
|
|
-// @Param request body models.EditReportChapterReq true "type json string"
|
|
|
-// @Success 200 Ret=200 保存成功
|
|
|
-// @router /addChapter [post]
|
|
|
-func (this *ReportController) AddDayWeekChapter() {
|
|
|
- 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
|
|
|
+ if req.Content == "" {
|
|
|
+ br.Msg = "请输入内容"
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- var req models.AddReportChapterReq
|
|
|
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ if req.AddType == 0 {
|
|
|
+ br.Msg = "请选择新增方式"
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if req.ReportId <= 0 {
|
|
|
- br.Msg = "报告ID有误"
|
|
|
+ reqTickerList := req.TickerList
|
|
|
+
|
|
|
+ chapterInfo, err := models.GetReportChapterInfoById(req.ReportChapterId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "章节信息有误"
|
|
|
+ br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 获取报告详情
|
|
|
- reportInfo, err := models.GetReportById(req.ReportId)
|
|
|
+ reportInfo, err := models.GetReportById(chapterInfo.ReportId)
|
|
|
if err != nil {
|
|
|
- br.Msg = "报告信息有误"
|
|
|
- br.ErrMsg = "报告信息有误, Err: " + err.Error()
|
|
|
+ br.Msg = "查询报告有误"
|
|
|
+ br.ErrMsg = "查询报告信息失败, Err: " + err.Error()
|
|
|
return
|
|
|
}
|
|
|
if reportInfo.State == 2 {
|
|
@@ -981,141 +885,70 @@ func (this *ReportController) AddDayWeekChapter() {
|
|
|
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
|
|
|
- }
|
|
|
-
|
|
|
- reportChapterInfo := new(models.ReportChapter)
|
|
|
- reportChapterInfo.ReportId = reportInfo.Id
|
|
|
- reportChapterInfo.ClassifyIdFirst = reportInfo.ClassifyIdFirst
|
|
|
- reportChapterInfo.ClassifyNameFirst = reportInfo.ClassifyNameFirst
|
|
|
-
|
|
|
- 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.VideoKind = 1
|
|
|
-
|
|
|
- reportChapterInfo.ClassifyIdSecond = reportInfo.ClassifyIdSecond
|
|
|
- reportChapterInfo.ClassifyNameSecond = reportInfo.ClassifyNameSecond
|
|
|
- reportChapterInfo.ClassifyIdThird = reportInfo.ClassifyIdThird
|
|
|
- reportChapterInfo.ClassifyNameThird = reportInfo.ClassifyNameThird
|
|
|
- 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()
|
|
|
- if err != nil {
|
|
|
- br.Msg = "新增失败"
|
|
|
- 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 = "保存成功"
|
|
|
-}
|
|
|
-
|
|
|
-// EditDayWeekChapter
|
|
|
-// @Title 编辑晨周报章节内容
|
|
|
-// @Description 编辑晨周报章节内容
|
|
|
-// @Param request body models.EditReportChapterReq true "type json string"
|
|
|
-// @Success 200 Ret=200 保存成功
|
|
|
-// @router /editDayWeekChapter [post]
|
|
|
-func (this *ReportController) EditDayWeekChapter() {
|
|
|
- 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
|
|
|
+ // 图表刷新状态
|
|
|
+ refreshResult := data.CheckBatchChartRefreshResult("report", chapterInfo.ReportId, chapterInfo.ReportChapterId)
|
|
|
+ if !refreshResult {
|
|
|
+ br.Msg = "图表刷新未完成,请稍后操作"
|
|
|
+ br.ErrMsg = "图表刷新未完成,请稍后操作"
|
|
|
+ br.IsSendEmail = false
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- var req models.EditReportChapterReq
|
|
|
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ // 获取规则配置
|
|
|
+ reportChapterTypeRule, err := models.GetReportChapterTypeById(chapterInfo.TypeId)
|
|
|
if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- reportChapterId := req.ReportChapterId
|
|
|
- if reportChapterId <= 0 {
|
|
|
- br.Msg = "报告章节ID有误"
|
|
|
- return
|
|
|
- }
|
|
|
- if req.Content == "" {
|
|
|
- br.Msg = "请输入内容"
|
|
|
+ br.Msg = "获取配置信息异常"
|
|
|
+ br.ErrMsg = "获取配置信息异常, Err: " + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- //if req.AddType == 0 {
|
|
|
- // br.Msg = "请选择新增方式"
|
|
|
- // return
|
|
|
- //}
|
|
|
- // 获取章节详情
|
|
|
- reportChapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "报告章节信息有误"
|
|
|
- br.ErrMsg = "报告章节信息有误, Err: " + err.Error()
|
|
|
+ if reportChapterTypeRule.Enabled == 0 {
|
|
|
+ br.Msg = "该章节已永久停更"
|
|
|
+ br.ErrMsg = "该章节已永久停更 "
|
|
|
+ br.IsSendEmail = false
|
|
|
return
|
|
|
}
|
|
|
- // 获取报告详情
|
|
|
- reportInfo, err := models.GetReportById(reportChapterInfo.ReportId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "报告信息有误"
|
|
|
- br.ErrMsg = "报告信息有误, Err: " + err.Error()
|
|
|
- return
|
|
|
+
|
|
|
+ updateCols := make([]string, 0)
|
|
|
+ updateCols = append(updateCols, "Title", "AddType", "Author", "Content", "ContentSub", "IsEdit", "CreateTime", "PublishState", "PublishTime")
|
|
|
+
|
|
|
+ var needHandleVideo bool // 是否需要处理音频文件
|
|
|
+ nowTime := time.Now()
|
|
|
+ var publishTime time.Time
|
|
|
+ if reportInfo.MsgIsSend == 1 && reportInfo.PublishTime != "" { //如果报告曾经发布过,并且已经发送过模版消息,则章节的发布时间为报告的发布时间
|
|
|
+ publishTime, _ = time.ParseInLocation(utils.FormatDateTime, reportInfo.PublishTime, time.Local)
|
|
|
+ } else {
|
|
|
+ publishTime = time.Now()
|
|
|
}
|
|
|
- if reportInfo.State == 2 {
|
|
|
- br.Msg = "该报告已发布,不允许编辑"
|
|
|
- br.ErrMsg = "该报告已发布,不允许编辑"
|
|
|
- return
|
|
|
+ if req.VideoUrl != "" {
|
|
|
+ chapterInfo.VideoUrl = req.VideoUrl
|
|
|
+ chapterInfo.VideoName = req.VideoName
|
|
|
+ chapterInfo.VideoSize = req.VideoSize
|
|
|
+ chapterInfo.VideoPlaySeconds = req.VideoPlaySeconds
|
|
|
+ chapterInfo.VideoKind = 1
|
|
|
+
|
|
|
+ updateCols = append(updateCols, "VideoUrl", "VideoName", "VideoSize", "VideoPlaySeconds", "VideoKind")
|
|
|
+
|
|
|
+ // 手动上传的音频需要处理音频文件
|
|
|
+ needHandleVideo = true
|
|
|
+ } else {
|
|
|
+ if chapterInfo.VideoUrl == "" {
|
|
|
+ // 生成video
|
|
|
+ videoUrl, videoName, videoSize, videoPlaySeconds, err := services.CreateReportVideo(req.Title, req.Content, publishTime.Format(utils.FormatDateTime))
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "生成video失败"
|
|
|
+ br.ErrMsg = "生成video失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ chapterInfo.VideoUrl = videoUrl
|
|
|
+ chapterInfo.VideoName = videoName
|
|
|
+ chapterInfo.VideoSize = videoSize
|
|
|
+ chapterInfo.VideoPlaySeconds = fmt.Sprintf("%.2f", videoPlaySeconds)
|
|
|
+ chapterInfo.VideoKind = 2
|
|
|
+ updateCols = append(updateCols, "VideoUrl", "VideoName", "VideoSize", "VideoPlaySeconds", "VideoKind")
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- reqTickerList := req.TickerList
|
|
|
- // 更新章节及指标
|
|
|
+ // 更新章节信息
|
|
|
contentSub := ""
|
|
|
if req.Content != "" {
|
|
|
e := utils.ContentXssCheck(req.Content)
|
|
@@ -1139,43 +972,22 @@ func (this *ReportController) EditDayWeekChapter() {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+ chapterInfo.Title = req.Title
|
|
|
+ chapterInfo.AddType = req.AddType
|
|
|
+ chapterInfo.Author = req.Author
|
|
|
+ chapterInfo.Content = html.EscapeString(req.Content)
|
|
|
+ chapterInfo.ContentSub = html.EscapeString(contentSub)
|
|
|
+ chapterInfo.IsEdit = 1
|
|
|
+ chapterInfo.CreateTime = req.CreateTime
|
|
|
+ chapterInfo.PublishState = 2
|
|
|
+ chapterInfo.PublishTime = publishTime
|
|
|
|
|
|
- reportChapterInfo.Title = req.Title
|
|
|
- //reportChapterInfo.AddType = req.AddType
|
|
|
- reportChapterInfo.Author = req.Author
|
|
|
- reportChapterInfo.Content = html.EscapeString(req.Content)
|
|
|
- reportChapterInfo.ContentSub = html.EscapeString(contentSub)
|
|
|
- reportChapterInfo.IsEdit = 1
|
|
|
- reportChapterInfo.CreateTime = req.CreateTime
|
|
|
- reportChapterInfo.VideoUrl = req.VideoUrl
|
|
|
- reportChapterInfo.VideoName = req.VideoName
|
|
|
- reportChapterInfo.VideoPlaySeconds = req.VideoPlaySeconds
|
|
|
- reportChapterInfo.VideoSize = req.VideoSize
|
|
|
- reportChapterInfo.VideoKind = 1
|
|
|
-
|
|
|
- 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
|
|
|
-
|
|
|
- updateCols := make([]string, 0)
|
|
|
- updateCols = append(updateCols, "Title", "AddType", "Author", "Content", "ContentSub", "IsEdit", "CreateTime")
|
|
|
- if req.VideoUrl != "" {
|
|
|
- updateCols = append(updateCols, "VideoUrl", "VideoName", "VideoSize", "VideoPlaySeconds", "VideoKind")
|
|
|
- }
|
|
|
-
|
|
|
- updateCols = append(updateCols, "LastModifyAdminId", "LastModifyAdminName", "ContentModifyTime", "ContentStruct", "CanvasColor", "HeadResourceId", "EndResourceId")
|
|
|
-
|
|
|
- // 章节报告更新指标
|
|
|
+ // 晨报更新指标
|
|
|
tickerList := make([]*models.ReportChapterTicker, 0)
|
|
|
- if len(reqTickerList) > 0 {
|
|
|
- nowTime := time.Now()
|
|
|
+ if chapterInfo.ReportType == "day" && len(reqTickerList) > 0 {
|
|
|
for i := 0; i < len(reqTickerList); i++ {
|
|
|
tickerList = append(tickerList, &models.ReportChapterTicker{
|
|
|
- ReportChapterId: reportChapterInfo.ReportChapterId,
|
|
|
+ ReportChapterId: chapterInfo.ReportChapterId,
|
|
|
Sort: reqTickerList[i].Sort,
|
|
|
Ticker: reqTickerList[i].Ticker,
|
|
|
CreateTime: nowTime,
|
|
@@ -1183,543 +995,227 @@ func (this *ReportController) EditDayWeekChapter() {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- err = models.UpdateChapterAndTicker(reportChapterInfo, updateCols, tickerList)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "保存失败"
|
|
|
+ if err = models.UpdateChapterAndTicker(chapterInfo, updateCols, tickerList); err != nil {
|
|
|
+ br.Msg = "发布失败"
|
|
|
br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ // 更新章节ES
|
|
|
+ {
|
|
|
+ go services.UpdateReportChapterEs(chapterInfo.ReportChapterId)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同时发布报告
|
|
|
+ if req.PublishReport == 1 {
|
|
|
+ if _, e := services.PublishDayWeekReport(chapterInfo.ReportId); e != nil {
|
|
|
+ br.Msg = "章节发布成功,报告发布失败,请手动发布报告"
|
|
|
+ br.ErrMsg = "发布晨/周报失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 备份关键数据
|
|
|
- chapters := make([]*models.ReportChapter, 0)
|
|
|
- chapters = append(chapters, reportChapterInfo)
|
|
|
- go services.SaveReportLogs(nil, chapters, sysUser.AdminId, sysUser.RealName)
|
|
|
+ // 处理报告中的音频文件分贝
|
|
|
+ if needHandleVideo {
|
|
|
+ go services.HandleVideoDecibel(chapterInfo)
|
|
|
+ }
|
|
|
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
- br.Msg = "保存成功"
|
|
|
+ br.Msg = "操作成功"
|
|
|
}
|
|
|
|
|
|
-// EditChapterBaseInfoAndPermission
|
|
|
-// @Title 修改报告章节的基础信息、授权用户权限、品种权限
|
|
|
-// @Description 修改报告章节的基础信息、授权用户权限、品种权限
|
|
|
-// @Param request body models.EditReportChapterReq true "type json string"
|
|
|
-// @Success 200 Ret=200 保存成功
|
|
|
-// @router /chapter/base_info/edit [post]
|
|
|
-func (this *ReportController) EditChapterBaseInfoAndPermission() {
|
|
|
+// AuthorizedListReport
|
|
|
+// @Title 获取有权限的报告列表接口
|
|
|
+// @Description 获取有权限的报告列表接口
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param KeyWord query string true "搜索关键词"
|
|
|
+// @Param ClassifyIdFirst query int true "一级分类id"
|
|
|
+// @Param ClassifyIdSecond query int true "二级分类id"
|
|
|
+// @Param ClassifyIdThird query int true "三级分类id"
|
|
|
+// @Success 200 {object} models.ReportListResp
|
|
|
+// @router /list/authorized [get]
|
|
|
+func (this *ReportController) AuthorizedListReport() {
|
|
|
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
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ keyword := this.GetString("KeyWord")
|
|
|
+ classifyIdFirst, _ := this.GetInt("ClassifyIdFirst", 0)
|
|
|
+ classifyIdSecond, _ := this.GetInt("ClassifyIdSecond", 0)
|
|
|
+ classifyIdThird, _ := this.GetInt("ClassifyIdThird", 0)
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
}
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+ var list []*models.ReportList
|
|
|
|
|
|
- var req models.EditReportChapterBaseInfoAndPermissionReq
|
|
|
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ // 没有输入信息,那就不展示
|
|
|
+ if keyword == `` {
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, 0)
|
|
|
+ resp := new(models.ReportListResp)
|
|
|
+ resp.Paging = page
|
|
|
+ resp.List = list
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
return
|
|
|
}
|
|
|
- reportChapterId := req.ReportChapterId
|
|
|
- if reportChapterId <= 0 {
|
|
|
- br.Msg = "报告章节ID有误"
|
|
|
- return
|
|
|
+
|
|
|
+ // 当前用户有权限的报告id列表
|
|
|
+ grantReportIdList := make([]int, 0)
|
|
|
+ {
|
|
|
+ obj := report.ReportGrant{}
|
|
|
+ grantList, err := obj.GetGrantListByAdminId(this.SysUser.AdminId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取授权报告id失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range grantList {
|
|
|
+ grantReportIdList = append(grantReportIdList, v.ReportId)
|
|
|
+ }
|
|
|
}
|
|
|
- // 获取章节详情
|
|
|
- reportChapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "报告章节信息有误"
|
|
|
- br.ErrMsg = "报告章节信息有误, Err: " + err.Error()
|
|
|
- return
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ condition += ` AND a.title LIKE ? `
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, keyword, 1)
|
|
|
+
|
|
|
+ if classifyIdFirst > 0 {
|
|
|
+ condition += ` AND a.classify_id_first = ? `
|
|
|
+ pars = append(pars, classifyIdFirst)
|
|
|
}
|
|
|
- // 获取报告详情
|
|
|
- reportInfo, err := models.GetReportByReportId(reportChapterInfo.ReportId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "报告信息有误"
|
|
|
- br.ErrMsg = "报告信息有误, Err: " + err.Error()
|
|
|
- return
|
|
|
+ if classifyIdSecond > 0 {
|
|
|
+ condition += ` AND a.classify_id_second = ? `
|
|
|
+ pars = append(pars, classifyIdSecond)
|
|
|
}
|
|
|
- if reportInfo.State == 2 {
|
|
|
- br.Msg = "该报告已发布,不允许编辑"
|
|
|
- br.ErrMsg = "该报告已发布,不允许编辑"
|
|
|
- return
|
|
|
+ if classifyIdThird > 0 {
|
|
|
+ condition += ` AND a.classify_id_third = ? `
|
|
|
+ pars = append(pars, classifyIdSecond)
|
|
|
}
|
|
|
|
|
|
- err, errMsg := services.EditChapterBaseInfoAndPermission(reportInfo, reportChapterInfo, req.Title, req.PermissionIdList, req.AdminIdList)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "保存失败"
|
|
|
- if errMsg != "" {
|
|
|
- br.Msg = errMsg
|
|
|
- }
|
|
|
- br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
+ var err error
|
|
|
+ var total int
|
|
|
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Msg = "保存成功"
|
|
|
-}
|
|
|
+ orCondition := `AND ( (a.is_public_publish = ? AND a.state in (2,6)) or a.admin_id = ? `
|
|
|
+ pars = append(pars, 1, this.SysUser.AdminId)
|
|
|
|
|
|
-// GetDayWeekChapter
|
|
|
-// @Title 获取晨周报章节信息
|
|
|
-// @Description 获取晨周报章节信息
|
|
|
-// @Param ReportChapterId query int true "报告章节ID"
|
|
|
-// @Success 200 Ret=200 保存成功
|
|
|
-// @router /getDayWeekChapter [get]
|
|
|
-func (this *ReportController) GetDayWeekChapter() {
|
|
|
- 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
|
|
|
+ // 当前用户有权限的报告id列表
|
|
|
+ num := len(grantReportIdList)
|
|
|
+ if num > 0 {
|
|
|
+ orCondition += ` OR a.id in (` + utils.GetOrmInReplace(num) + `)`
|
|
|
+ pars = append(pars, grantReportIdList)
|
|
|
}
|
|
|
+ orCondition += ` ) `
|
|
|
|
|
|
- reportChapterId, _ := this.GetInt("ReportChapterId")
|
|
|
- if reportChapterId <= 0 {
|
|
|
- br.Msg = "参数有误"
|
|
|
+ condition += orCondition
|
|
|
+
|
|
|
+ total, err = models.GetReportListCountByAuthorized(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- chapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
|
|
|
+ list, err = models.GetReportListByAuthorized(condition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取章节信息失败"
|
|
|
- br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
|
|
|
+ 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)
|
|
|
- }
|
|
|
|
|
|
+ //for _, item := range list {
|
|
|
+ // if item.HasChapter == 1 {
|
|
|
+ // item.CanEdit = true
|
|
|
+ // } else {
|
|
|
+ // markStatus, err := services.UpdateReportEditMark(item.Id, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
|
|
|
+ // if err != nil {
|
|
|
+ // br.Msg = "查询标记状态失败"
|
|
|
+ // br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // if markStatus.Status == 0 {
|
|
|
+ // item.CanEdit = true
|
|
|
+ // } else {
|
|
|
+ // item.Editor = markStatus.Editor
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp := new(models.ReportListResp)
|
|
|
+ resp.Paging = page
|
|
|
+ resp.List = list
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|
|
|
- br.Data = chapterInfo
|
|
|
+ br.Data = resp
|
|
|
}
|
|
|
|
|
|
-// PublishDayWeekReportChapter
|
|
|
-// @Title 发布晨周报章节
|
|
|
-// @Description 发布晨周报章节
|
|
|
-// @Param request body models.PublishReportChapterReq true "type json string"
|
|
|
-// @Success 200 Ret=200 操作成功
|
|
|
-// @router /publishDayWeekReportChapter [post]
|
|
|
-func (this *ReportController) PublishDayWeekReportChapter() {
|
|
|
+// BaseDetail
|
|
|
+// @Title 获取报告基础信息详情接口
|
|
|
+// @Description 获取报告基础信息详情接口
|
|
|
+// @Param request body models.ReportDetailReq true "type json string"
|
|
|
+// @Success 200 {object} models.Report
|
|
|
+// @router /detail/base [get]
|
|
|
+func (this *ReportController) BaseDetail() {
|
|
|
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
|
|
|
+ /*var req models.ReportDetailReq
|
|
|
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
|
|
|
- }
|
|
|
- if req.Title == "" {
|
|
|
- br.Msg = "请输入标题"
|
|
|
- return
|
|
|
- }
|
|
|
- if req.Content == "" {
|
|
|
- br.Msg = "请输入内容"
|
|
|
- return
|
|
|
- }
|
|
|
- if req.AddType == 0 {
|
|
|
- br.Msg = "请选择新增方式"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- reqTickerList := req.TickerList
|
|
|
-
|
|
|
- chapterInfo, err := models.GetReportChapterInfoById(req.ReportChapterId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "章节信息有误"
|
|
|
- br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
|
|
|
+ if req.ReportId <= 0 {
|
|
|
+ br.Msg = "参数错误"
|
|
|
return
|
|
|
- }
|
|
|
-
|
|
|
- reportInfo, err := models.GetReportById(chapterInfo.ReportId)
|
|
|
+ }*/
|
|
|
+ reportId, err := this.GetInt("ReportId")
|
|
|
if err != nil {
|
|
|
- br.Msg = "查询报告有误"
|
|
|
- br.ErrMsg = "查询报告信息失败, Err: " + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if reportInfo.State == 2 {
|
|
|
- br.Msg = "该报告已发布,不允许编辑"
|
|
|
- br.ErrMsg = "该报告已发布,不允许编辑"
|
|
|
+ br.Msg = "获取参数失败!"
|
|
|
+ br.ErrMsg = "获取参数失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- // 图表刷新状态
|
|
|
- refreshResult := data.CheckBatchChartRefreshResult("report", chapterInfo.ReportId, chapterInfo.ReportChapterId)
|
|
|
- if !refreshResult {
|
|
|
- br.Msg = "图表刷新未完成,请稍后操作"
|
|
|
- br.ErrMsg = "图表刷新未完成,请稍后操作"
|
|
|
- br.IsSendEmail = false
|
|
|
+ if reportId <= 0 {
|
|
|
+ br.Msg = "参数错误"
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- // 获取规则配置
|
|
|
- reportChapterTypeRule, err := models.GetReportChapterTypeById(chapterInfo.TypeId)
|
|
|
+ item, err := models.GetReportById(reportId)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取配置信息异常"
|
|
|
- br.ErrMsg = "获取配置信息异常, Err: " + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if reportChapterTypeRule.Enabled == 0 {
|
|
|
- br.Msg = "该章节已永久停更"
|
|
|
- br.ErrMsg = "该章节已永久停更 "
|
|
|
- br.IsSendEmail = false
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- updateCols := make([]string, 0)
|
|
|
- updateCols = append(updateCols, "Title", "AddType", "Author", "Content", "ContentSub", "IsEdit", "CreateTime", "PublishState", "PublishTime")
|
|
|
-
|
|
|
- var needHandleVideo bool // 是否需要处理音频文件
|
|
|
- nowTime := time.Now()
|
|
|
- var publishTime time.Time
|
|
|
- if reportInfo.MsgIsSend == 1 && reportInfo.PublishTime != "" { //如果报告曾经发布过,并且已经发送过模版消息,则章节的发布时间为报告的发布时间
|
|
|
- publishTime, _ = time.ParseInLocation(utils.FormatDateTime, reportInfo.PublishTime, time.Local)
|
|
|
- } else {
|
|
|
- publishTime = time.Now()
|
|
|
- }
|
|
|
- if req.VideoUrl != "" {
|
|
|
- chapterInfo.VideoUrl = req.VideoUrl
|
|
|
- chapterInfo.VideoName = req.VideoName
|
|
|
- chapterInfo.VideoSize = req.VideoSize
|
|
|
- chapterInfo.VideoPlaySeconds = req.VideoPlaySeconds
|
|
|
- chapterInfo.VideoKind = 1
|
|
|
-
|
|
|
- updateCols = append(updateCols, "VideoUrl", "VideoName", "VideoSize", "VideoPlaySeconds", "VideoKind")
|
|
|
-
|
|
|
- // 手动上传的音频需要处理音频文件
|
|
|
- needHandleVideo = true
|
|
|
- } else {
|
|
|
- if chapterInfo.VideoUrl == "" {
|
|
|
- // 生成video
|
|
|
- videoUrl, videoName, videoSize, videoPlaySeconds, err := services.CreateReportVideo(req.Title, req.Content, publishTime.Format(utils.FormatDateTime))
|
|
|
- if err != nil {
|
|
|
- br.Msg = "生成video失败"
|
|
|
- br.ErrMsg = "生成video失败, Err: " + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- chapterInfo.VideoUrl = videoUrl
|
|
|
- chapterInfo.VideoName = videoName
|
|
|
- chapterInfo.VideoSize = videoSize
|
|
|
- chapterInfo.VideoPlaySeconds = fmt.Sprintf("%.2f", videoPlaySeconds)
|
|
|
- chapterInfo.VideoKind = 2
|
|
|
- updateCols = append(updateCols, "VideoUrl", "VideoName", "VideoSize", "VideoPlaySeconds", "VideoKind")
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 更新章节信息
|
|
|
- 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()
|
|
|
+ if err.Error() == utils.ErrNoRow() {
|
|
|
+ br.Msg = "报告已被删除"
|
|
|
return
|
|
|
}
|
|
|
- }
|
|
|
- chapterInfo.Title = req.Title
|
|
|
- chapterInfo.AddType = req.AddType
|
|
|
- chapterInfo.Author = req.Author
|
|
|
- chapterInfo.Content = html.EscapeString(req.Content)
|
|
|
- chapterInfo.ContentSub = html.EscapeString(contentSub)
|
|
|
- chapterInfo.IsEdit = 1
|
|
|
- chapterInfo.CreateTime = req.CreateTime
|
|
|
- chapterInfo.PublishState = 2
|
|
|
- chapterInfo.PublishTime = publishTime
|
|
|
-
|
|
|
- // 晨报更新指标
|
|
|
- tickerList := make([]*models.ReportChapterTicker, 0)
|
|
|
- if chapterInfo.ReportType == "day" && len(reqTickerList) > 0 {
|
|
|
- for i := 0; i < len(reqTickerList); i++ {
|
|
|
- tickerList = append(tickerList, &models.ReportChapterTicker{
|
|
|
- ReportChapterId: chapterInfo.ReportChapterId,
|
|
|
- Sort: reqTickerList[i].Sort,
|
|
|
- Ticker: reqTickerList[i].Ticker,
|
|
|
- CreateTime: nowTime,
|
|
|
- UpdateTime: nowTime,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- if err = models.UpdateChapterAndTicker(chapterInfo, updateCols, tickerList); err != nil {
|
|
|
- br.Msg = "发布失败"
|
|
|
- br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- // 更新章节ES
|
|
|
- {
|
|
|
- go services.UpdateReportChapterEs(chapterInfo.ReportChapterId)
|
|
|
- }
|
|
|
-
|
|
|
- // 同时发布报告
|
|
|
- if req.PublishReport == 1 {
|
|
|
- if _, e := services.PublishDayWeekReport(chapterInfo.ReportId); e != nil {
|
|
|
- br.Msg = "章节发布成功,报告发布失败,请手动发布报告"
|
|
|
- br.ErrMsg = "发布晨/周报失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 处理报告中的音频文件分贝
|
|
|
- if needHandleVideo {
|
|
|
- go services.HandleVideoDecibel(chapterInfo)
|
|
|
- }
|
|
|
-
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Msg = "操作成功"
|
|
|
-}
|
|
|
-
|
|
|
-// AuthorizedListReport
|
|
|
-// @Title 获取有权限的报告列表接口
|
|
|
-// @Description 获取有权限的报告列表接口
|
|
|
-// @Param PageSize query int true "每页数据条数"
|
|
|
-// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
-// @Param KeyWord query string true "搜索关键词"
|
|
|
-// @Success 200 {object} models.ReportListResp
|
|
|
-// @router /list/authorized [get]
|
|
|
-func (this *ReportController) AuthorizedListReport() {
|
|
|
- br := new(models.BaseResponse).Init()
|
|
|
- defer func() {
|
|
|
- this.Data["json"] = br
|
|
|
- this.ServeJSON()
|
|
|
- }()
|
|
|
- pageSize, _ := this.GetInt("PageSize")
|
|
|
- currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
-
|
|
|
- timeType := this.GetString("TimeType")
|
|
|
- keyWord := this.GetString("KeyWord")
|
|
|
- filterReportType, _ := this.GetInt("FilterReportType", 1)
|
|
|
-
|
|
|
- var startSize int
|
|
|
- if pageSize <= 0 {
|
|
|
- pageSize = utils.PageSize20
|
|
|
- }
|
|
|
- if currentIndex <= 0 {
|
|
|
- currentIndex = 1
|
|
|
- }
|
|
|
- startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
-
|
|
|
- if timeType == "" {
|
|
|
- timeType = "publish_time"
|
|
|
- }
|
|
|
- var condition string
|
|
|
- var pars []interface{}
|
|
|
-
|
|
|
- if keyWord != "" {
|
|
|
- condition += ` AND (a.title LIKE ? OR a.admin_real_name LIKE ? ) `
|
|
|
- pars = utils.GetLikeKeywordPars(pars, keyWord, 2)
|
|
|
- }
|
|
|
-
|
|
|
- var err error
|
|
|
- var total int
|
|
|
- var list []*models.ReportList
|
|
|
-
|
|
|
- switch filterReportType {
|
|
|
- // 筛选报告类型,1:公共研报,2:共享研报,3:我的研报
|
|
|
- case 1:
|
|
|
- condition += ` AND a.is_public_publish = ? AND a.state in (2,6)`
|
|
|
- pars = append(pars, 1)
|
|
|
- case 3:
|
|
|
- condition += ` AND a.admin_id = ? `
|
|
|
- pars = append(pars, this.SysUser.AdminId)
|
|
|
- case 2:
|
|
|
- condition += ` AND (a.admin_id = ? or b.admin_id = ?) `
|
|
|
- pars = append(pars, this.SysUser.AdminId, this.SysUser.AdminId)
|
|
|
- }
|
|
|
-
|
|
|
- // 共享报告需要连表查询,所以需要单独写
|
|
|
- if filterReportType == 2 {
|
|
|
- total, err = models.GetReportListCountByGrant(condition, pars)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- list, err = models.GetReportListByGrant(condition, pars, startSize, pageSize)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- total, err = models.GetReportListCountV1(condition, pars)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- list, err = models.GetReportListV1(condition, pars, startSize, pageSize)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- listLen := len(list)
|
|
|
- if listLen > 0 {
|
|
|
- pvMap := make(map[int]int)
|
|
|
- uvMap := make(map[int]int)
|
|
|
- reportIdArr := make([]string, 0)
|
|
|
- syncReportIdArr := make([]string, 0) // 同步过来的报告IDs
|
|
|
- oldAndNewReportIdMap := make(map[int]int) // 旧报告和新报告的id对应关系
|
|
|
- for i := 0; i < listLen; i++ {
|
|
|
- reportIdArr = append(reportIdArr, strconv.Itoa(list[i].Id))
|
|
|
- if list[i].OldReportId > 0 {
|
|
|
- syncReportIdArr = append(syncReportIdArr, strconv.Itoa(list[i].OldReportId))
|
|
|
- oldAndNewReportIdMap[list[i].OldReportId] = list[i].Id
|
|
|
- }
|
|
|
- pvMap[list[i].Id] = list[i].Pv
|
|
|
- uvMap[list[i].Id] = list[i].Uv
|
|
|
- }
|
|
|
|
|
|
- // 当下报告的pv,uv
|
|
|
- if len(reportIdArr) > 0 {
|
|
|
- pvList, e := models.GetReportPvUvByReportIdList(reportIdArr)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取同步报告对应的PV、UV失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- for _, v := range pvList {
|
|
|
- pv := pvMap[v.ReportId]
|
|
|
- uv := uvMap[v.ReportId]
|
|
|
- pvMap[v.ReportId] = v.PvTotal + pv
|
|
|
- uvMap[v.ReportId] = v.UvTotal + uv
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //reportIds := strings.Join(reportIdArr, ",")
|
|
|
- //syncReportIds := strings.Join(syncReportIdArr, ",")
|
|
|
+ // 基础信息就不获取章节信息了
|
|
|
+ chapterList := make([]*models.ReportChapter, 0)
|
|
|
|
|
|
- // 查询同步过来的报告对应的老报告PV+UV
|
|
|
- if len(syncReportIdArr) > 0 {
|
|
|
- puvList, e := models.GetPUVByResearchReportIds(syncReportIdArr)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取同步报告对应的PV、UV失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- puvLen := len(puvList)
|
|
|
- for i := 0; i < puvLen; i++ {
|
|
|
- newReportId, ok := oldAndNewReportIdMap[puvList[i].ResearchReportId]
|
|
|
- if ok {
|
|
|
- pv := pvMap[newReportId]
|
|
|
- uv := uvMap[newReportId]
|
|
|
- pvMap[newReportId] = puvList[i].Pv + pv
|
|
|
- uvMap[newReportId] = puvList[i].Uv + uv
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 晨周报音频列表
|
|
|
- videoList, err := models.GetReportChapterVideoListByReportIds(reportIdArr)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取报告音频文件失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- for i := 0; i < listLen; i++ {
|
|
|
- list[i].Content = html.UnescapeString(list[i].Content)
|
|
|
- list[i].ContentSub = html.UnescapeString(list[i].ContentSub)
|
|
|
- // 除周报外其余报告均可推送客群
|
|
|
- list[i].NeedThsMsg = 1
|
|
|
- //if list[i].HasChapter == 1 && list[i].ChapterType == utils.REPORT_TYPE_WEEK {
|
|
|
- // list[i].NeedThsMsg = 0
|
|
|
- //}
|
|
|
- chapterList := make([]*models.ReportChapterVideoList, 0)
|
|
|
- for ii := 0; ii < len(videoList); ii++ {
|
|
|
- if list[i].Id == videoList[ii].ReportId {
|
|
|
- chapterList = append(chapterList, videoList[ii])
|
|
|
- }
|
|
|
- }
|
|
|
- list[i].ChapterVideoList = chapterList
|
|
|
- list[i].Pv += pvMap[list[i].Id]
|
|
|
- list[i].Uv += uvMap[list[i].Id]
|
|
|
- }
|
|
|
- }
|
|
|
+ item.Content = html.UnescapeString(item.Content)
|
|
|
+ item.ContentSub = html.UnescapeString(item.ContentSub)
|
|
|
|
|
|
- for _, item := range list {
|
|
|
- /*key := fmt.Sprint(`crm:report:edit:`, item.Id)
|
|
|
- opUserId, _ := utils.Rc.RedisInt(key)
|
|
|
- //如果当前没有人操作,获取当前操作人是本人,那么编辑按钮可用
|
|
|
- if opUserId <= 0 || (opUserId == this.SysUser.AdminId) || item.ClassifyNameFirst == "周报" || item.ClassifyNameFirst == "晨报" {
|
|
|
- item.CanEdit = true
|
|
|
- } else {
|
|
|
- adminInfo, errAdmin := system.GetSysUserById(opUserId)
|
|
|
- if errAdmin != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- item.Editor = adminInfo.RealName
|
|
|
- }*/
|
|
|
- if item.ClassifyNameFirst == "周报" || item.ClassifyNameFirst == "晨报" {
|
|
|
- item.CanEdit = true
|
|
|
- } else {
|
|
|
- markStatus, err := services.UpdateReportEditMark(item.Id, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "查询标记状态失败"
|
|
|
- br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if markStatus.Status == 0 {
|
|
|
- item.CanEdit = true
|
|
|
- } else {
|
|
|
- item.Editor = markStatus.Editor
|
|
|
- }
|
|
|
- }
|
|
|
+ resp := &models.ReportDetailView{
|
|
|
+ ReportDetail: item,
|
|
|
+ ChapterList: chapterList,
|
|
|
}
|
|
|
-
|
|
|
- page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
- resp := new(models.ReportListResp)
|
|
|
- resp.Paging = page
|
|
|
- resp.List = list
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|