Parcourir la source

晨报周报不支持定时发布

xyxie il y a 1 an
Parent
commit
019894c548
2 fichiers modifiés avec 5 ajouts et 6 suppressions
  1. 1 2
      controllers/report.go
  2. 4 4
      models/report.go

+ 1 - 2
controllers/report.go

@@ -286,7 +286,6 @@ func (this *ReportController) PublishReport() {
 		var publishTime time.Time
 		if report.MsgIsSend == 1 && report.PublishTime != "" { //如果报告曾经发布过,并且已经发送过模版消息,则章节的发布时间为报告的发布时间
 			publishTime, _ = time.ParseInLocation(utils.FormatDateTime, report.PublishTime, time.Local)
-			// todo 发布时间调整
 		} else {
 			publishTime = time.Now()
 		}
@@ -3115,7 +3114,7 @@ func (this *ReportController) PrePublishReport() {
 		br.Msg = "报告不存在"
 		return
 	}
-	if report.ClassifyNameFirst == "晨报" || report.ClassifyNameFirst == "周报" {
+	if report.HasChapter == 1 && (report.ChapterType == utils.REPORT_TYPE_DAY || report.ChapterType == utils.REPORT_TYPE_WEEK) {
 		br.Msg = "晨报周报不支持定时发布"
 		return
 	}

+ 4 - 4
models/report.go

@@ -134,14 +134,14 @@ func PublishReport(reportIds string) (err error) {
 	return
 }
 
-// 取消发布报告
+// PublishCancleReport 取消发布报告
 func PublishCancleReport(reportIds int, publishTimeNullFlag bool) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	var sql string
 	if publishTimeNullFlag {
-		sql = ` UPDATE report SET state=1, publish_time=null WHERE id =?`
+		sql = ` UPDATE report SET state=1, publish_time=null, pre_publish_time=null WHERE id =?`
 	} else {
-		sql = ` UPDATE report SET state=1 WHERE id =?`
+		sql = ` UPDATE report SET state=1, pre_publish_time=null WHERE id =?`
 	}
 	_, err = o.Raw(sql, reportIds).Exec()
 	return
@@ -647,7 +647,7 @@ SELECT DISTINCT report_id FROM report_chapter WHERE publish_state = 2 AND (video
 // 发布报告
 func PublishReportById(reportId int, publishTime time.Time) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `UPDATE report SET state = 2, publish_time = ?, modify_time = NOW() WHERE id = ? `
+	sql := `UPDATE report SET state = 2, publish_time = ?, pre_publish_time=null, modify_time = NOW() WHERE id = ? `
 	_, err = o.Raw(sql, publishTime, reportId).Exec()
 	return
 }