|
@@ -281,6 +281,7 @@ func (this *EnglishReportController) Detail() {
|
|
|
// @Description 获取报告列表
|
|
|
// @Param PageSize query int true "每页数据条数"
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param TimeType query string true "筛选的时间类别:publish_time(发布时间),modify_time(更新时间)"
|
|
|
// @Param StartDate query string true "开始时间"
|
|
|
// @Param EndDate query string true "结束时间"
|
|
|
// @Param Frequency query string true "频度"
|
|
@@ -309,6 +310,7 @@ func (this *EnglishReportController) ListReport() {
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
|
|
|
+ timeType := this.GetString("TimeType")
|
|
|
startDate := this.GetString("StartDate")
|
|
|
endDate := this.GetString("EndDate")
|
|
|
frequency := this.GetString("Frequency")
|
|
@@ -335,12 +337,22 @@ func (this *EnglishReportController) ListReport() {
|
|
|
if keyWord != "" {
|
|
|
condition += ` AND (title LIKE '%` + keyWord + `%' OR author LIKE '%` + keyWord + `%' ) `
|
|
|
}
|
|
|
+
|
|
|
+ if timeType == "" {
|
|
|
+ timeType = "publish_time"
|
|
|
+ }
|
|
|
+ if timeType != "publish_time" && timeType != "modify_time" {
|
|
|
+ br.Msg = "请选择正确的时间"
|
|
|
+ br.ErrMsg = "请选择正确的时间"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if startDate != "" {
|
|
|
- condition += ` AND create_time >= ? `
|
|
|
+ condition += ` AND `+timeType+` >= ? `
|
|
|
pars = append(pars, startDate)
|
|
|
}
|
|
|
if endDate != "" {
|
|
|
- condition += ` AND create_time <= ? `
|
|
|
+ condition += ` AND `+timeType+` <= ? `
|
|
|
pars = append(pars, endDate)
|
|
|
}
|
|
|
if frequency != "" {
|
|
@@ -537,7 +549,14 @@ func (this *EnglishReportController) PublishReport() {
|
|
|
br.ErrMsg = "报告内容为空,不需要生成,report_id:" + strconv.Itoa(report.Id)
|
|
|
return
|
|
|
}
|
|
|
- if tmpErr = models.PublishEnglishReportById(report.Id); tmpErr != nil {
|
|
|
+ var publishTime string
|
|
|
+ if report.PublishTime != "" {
|
|
|
+ // 发布时间固定为首次发布时间
|
|
|
+ publishTime = report.PublishTime
|
|
|
+ } else {
|
|
|
+ publishTime = time.Now().Format(utils.FormatDateTime)
|
|
|
+ }
|
|
|
+ if tmpErr = models.PublishEnglishReportById(report.Id, publishTime); tmpErr != nil {
|
|
|
br.Msg = "报告发布失败"
|
|
|
br.ErrMsg = "报告发布失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(report.Id)
|
|
|
return
|
|
@@ -552,6 +571,78 @@ func (this *EnglishReportController) PublishReport() {
|
|
|
br.Msg = "发布成功"
|
|
|
}
|
|
|
|
|
|
+// @Title 设置定时发布接口
|
|
|
+// @Description 设置定时发布接口
|
|
|
+// @Param request body models.PrePublishReq true "type json string"
|
|
|
+// @Success 200 Ret=200 发布成功
|
|
|
+// @router /pre_publish [post]
|
|
|
+func (this *EnglishReportController) PrePublishReport() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ var req models.PrePublishReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportId := req.ReportId
|
|
|
+ if reportId == 0 {
|
|
|
+ br.Msg = "参数错误"
|
|
|
+ br.ErrMsg = "参数错误,报告id不可为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.PrePublishTime == "" {
|
|
|
+ br.Msg = "发布时间不能为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ prePublishTime, err := time.ParseInLocation(utils.FormatDateTime, req.PrePublishTime, time.Local)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "发布时间格式错误"
|
|
|
+ br.ErrMsg = "发布时间格式错误,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if prePublishTime.Before(time.Now()) {
|
|
|
+ br.Msg = "发布时间不允许选择过去时间"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ report, err := models.GetEnglishReportById(reportId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取报告信息失败"
|
|
|
+ br.ErrMsg = "获取报告信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if report == nil {
|
|
|
+ br.Msg = "报告不存在"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if report.Content == "" {
|
|
|
+ br.Msg = "报告内容为空,不可发布"
|
|
|
+ br.ErrMsg = "报告内容为空,不需要生成,report_id:" + strconv.Itoa(report.Id)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if report.State == 2 {
|
|
|
+ br.Msg = "报告已发布,不可设置定时发布"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var tmpErr error
|
|
|
+ if tmpErr = models.SetPrePublishEnglishReportById(report.Id, req.PrePublishTime); tmpErr != nil {
|
|
|
+ br.Msg = "设置定时发布失败"
|
|
|
+ br.ErrMsg = "设置定时发布失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(report.Id)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "定时发布成功"
|
|
|
+}
|
|
|
+
|
|
|
// @Title 取消发布报告接口
|
|
|
// @Description 取消发布报告
|
|
|
// @Param request body models.PublishCancelReq true "type json string"
|