|
@@ -117,7 +117,7 @@ func (r *ReportPdf) Update(cols []string) (err error) {
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- if (reportPushStatus == nil || err.Error() == utils.ErrNoRow()) && r.State == 1 {
|
|
|
+ if (reportPushStatus == nil || err.Error() == utils.ErrNoRow()) && r.State == utils.ReportStatusUp {
|
|
|
insertPushStatus := &ReportPushStatus{
|
|
|
ReportId: r.ReportPdfId,
|
|
|
State: 0,
|
|
@@ -137,22 +137,26 @@ func (r *ReportPdf) Update(cols []string) (err error) {
|
|
|
ModifyTime: time.Now(),
|
|
|
}
|
|
|
_, err = tx.Insert(insertPushStatus)
|
|
|
- } else {
|
|
|
- reportPushStatus.Title = r.Title
|
|
|
- reportPushStatus.Abstract = r.Abstract
|
|
|
- reportPushStatus.Stage = r.Stage
|
|
|
- reportPushStatus.ClassifyIdFirst = r.ClassifyIdFirst
|
|
|
- reportPushStatus.ClassifyNameFirst = r.ClassifyNameFirst
|
|
|
- reportPushStatus.ClassifyIdSecond = r.ClassifyIdSecond
|
|
|
- reportPushStatus.ClassifyNameSecond = r.ClassifyNameSecond
|
|
|
- reportPushStatus.ClassifyIdThird = r.ClassifyIdThird
|
|
|
- reportPushStatus.ClassifyNameThird = r.ClassifyNameThird
|
|
|
- reportPushStatus.Author = r.Author
|
|
|
- reportPushStatus.PublishTime = r.PublishTime
|
|
|
- reportPushStatus.ModifyTime = time.Now()
|
|
|
- _, err = tx.Update(reportPushStatus)
|
|
|
+ } else if reportPushStatus != nil || err.Error() != utils.ErrNoRow() {
|
|
|
+ // pdf报告发布后编辑,则更新report_push_status表, 若取消发布,则在推送表中删除
|
|
|
+ if r.State == utils.ReportStatusDown {
|
|
|
+ err = reportPushStatus.Delete()
|
|
|
+ } else {
|
|
|
+ reportPushStatus.Title = r.Title
|
|
|
+ reportPushStatus.Abstract = r.Abstract
|
|
|
+ reportPushStatus.Stage = r.Stage
|
|
|
+ reportPushStatus.ClassifyIdFirst = r.ClassifyIdFirst
|
|
|
+ reportPushStatus.ClassifyNameFirst = r.ClassifyNameFirst
|
|
|
+ reportPushStatus.ClassifyIdSecond = r.ClassifyIdSecond
|
|
|
+ reportPushStatus.ClassifyNameSecond = r.ClassifyNameSecond
|
|
|
+ reportPushStatus.ClassifyIdThird = r.ClassifyIdThird
|
|
|
+ reportPushStatus.ClassifyNameThird = r.ClassifyNameThird
|
|
|
+ reportPushStatus.Author = r.Author
|
|
|
+ reportPushStatus.PublishTime = r.PublishTime
|
|
|
+ reportPushStatus.ModifyTime = time.Now()
|
|
|
+ _, err = tx.Update(reportPushStatus)
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
return
|
|
|
}
|
|
|
|