|
@@ -7,6 +7,7 @@ import (
|
|
|
"eta/eta_api/models/data_manage/excel"
|
|
|
"eta/eta_api/utils"
|
|
|
"fmt"
|
|
|
+ "gorm.io/gorm"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
@@ -248,9 +249,51 @@ type EnglishReportDetail struct {
|
|
|
ClassifyNameRoot string `description:"顶级分类名称"`
|
|
|
}
|
|
|
|
|
|
+func (obj *EnglishReportDetail) AfterFind(tx *gorm.DB) (err error) {
|
|
|
+ if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
|
|
|
+ if obj.CreateTime != "" {
|
|
|
+ obj.CreateTime = utils.GormDateStrToDateTimeStr(obj.CreateTime)
|
|
|
+ }
|
|
|
+ if obj.ModifyTime != "" {
|
|
|
+ obj.ModifyTime = utils.GormDateStrToDateTimeStr(obj.ModifyTime)
|
|
|
+ }
|
|
|
+ if obj.PublishTime != "" {
|
|
|
+ obj.PublishTime = utils.GormDateStrToDateTimeStr(obj.PublishTime)
|
|
|
+ }
|
|
|
+ if obj.PrePublishTime != "" {
|
|
|
+ obj.PrePublishTime = utils.GormDateStrToDateTimeStr(obj.PrePublishTime)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (obj *EnglishReportDetail) ConvertTimeStr() {
|
|
|
+ if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
|
|
|
+ if obj.CreateTime != "" {
|
|
|
+ obj.CreateTime = utils.GormDateStrToDateTimeStr(obj.CreateTime)
|
|
|
+ }
|
|
|
+ if obj.ModifyTime != "" {
|
|
|
+ obj.ModifyTime = utils.GormDateStrToDateTimeStr(obj.ModifyTime)
|
|
|
+ }
|
|
|
+ if obj.PublishTime != "" {
|
|
|
+ obj.PublishTime = utils.GormDateStrToDateTimeStr(obj.PublishTime)
|
|
|
+ }
|
|
|
+ if obj.PrePublishTime != "" {
|
|
|
+ obj.PrePublishTime = utils.GormDateStrToDateTimeStr(obj.PrePublishTime)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func GetEnglishReportById(reportId int) (item *EnglishReportDetail, err error) {
|
|
|
sql := `SELECT * FROM english_report WHERE id=?`
|
|
|
err = global.DbMap[utils.DbNameReport].Raw(sql, reportId).First(&item).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if item != nil && item.Id > 0 {
|
|
|
+ item.ConvertTimeStr()
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -538,6 +581,12 @@ func GetEnglishReportDetailByClassifyId(classifyIdFirst, classifyIdSecond int) (
|
|
|
sql = sql + ` AND classify_id_first=? ORDER BY stage DESC LIMIT 1`
|
|
|
err = o.Raw(sql, classifyIdFirst).First(&item).Error
|
|
|
}
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if item != nil && item.Id > 0 {
|
|
|
+ item.ConvertTimeStr()
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|