Browse Source

fenwei时间格式处理

xyxie 1 month ago
parent
commit
59ee741d45
1 changed files with 27 additions and 4 deletions
  1. 27 4
      models/data_manage/base_from_fenwei.go

+ 27 - 4
models/data_manage/base_from_fenwei.go

@@ -3,12 +3,14 @@ package data_manage
 import (
 	"eta/eta_api/global"
 	"eta/eta_api/utils"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"gorm.io/gorm"
 )
 
 type BaseFromFenweiIndex struct {
-	FenweiIndexId int `orm:"column(fenwei_index_id);pk"`
+	FenweiIndexId int       `orm:"column(fenwei_index_id);pk" gorm:"primaryKey;"`
 	ClassifyId    int
 	IndexCode     string
 	IndexName     string
@@ -20,7 +22,7 @@ type BaseFromFenweiIndex struct {
 }
 
 type BaseFromFenweiIndexList struct {
-	FenweiIndexId int `orm:"column(fenwei_index_id);pk"`
+	FenweiIndexId int `orm:"column(fenwei_index_id);pk" gorm:"primaryKey;"`
 	ClassifyId    int
 	IndexCode     string
 	IndexName     string
@@ -34,6 +36,13 @@ type BaseFromFenweiIndexList struct {
 	EdbInfoId     int                   `description:"指标库主键id"`
 }
 
+func (b *BaseFromFenweiIndexList) AfterFind(tx *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		b.CreateTime = utils.GormDateStrToDateTimeStr(b.CreateTime)
+		b.ModifyTime = utils.GormDateStrToDateTimeStr(b.ModifyTime)
+	}
+	return
+}
 type FenweiSingleDataResp struct {
 	FenweiIndexId int
 	ClassifyId    int
@@ -137,7 +146,7 @@ func GetFenweiIndexDataByCodes(indexCode []string) (items []*BaseFromFenweiData,
 }
 
 type BaseFromFenweiData struct {
-	FenweiDataId  int `orm:"column(fenwei_data_id);pk"`
+	FenweiDataId  int `orm:"column(fenwei_data_id);pk" gorm:"primaryKey;"`
 	FenweiIndexId int
 	IndexCode     string
 	DataTime      string
@@ -147,6 +156,14 @@ type BaseFromFenweiData struct {
 	DataTimestamp int64
 }
 
+func (b *BaseFromFenweiData) AfterFind(tx *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		b.CreateTime = utils.GormDateStrToDateTimeStr(b.CreateTime)
+		b.ModifyTime = utils.GormDateStrToDateTimeStr(b.ModifyTime)
+		b.DataTime = utils.GormDateStrToDateTimeStr(b.DataTime)
+	}
+	return
+}
 type BaseFromFenweiIndexSearchItem struct {
 	FenweiIndexId int `orm:"column(fenwei_index_id);pk"`
 	ClassifyId    int
@@ -273,6 +290,12 @@ func GetFenWeiIndexInfoCount(condition string, pars []interface{}) (count int, e
 func GetFenWeiDataLastModifyTime(indexCode string) (lastModifyTime string, err error) {
 	sql := ` SELECT MAX(modify_time) AS last_modify_time FROM base_from_fenwei_data WHERE index_code=? `
 	err = global.DbMap[utils.DbNameIndex].Raw(sql, indexCode).Scan(&lastModifyTime).Error
+	if err != nil {
+		return
+	}
+	if lastModifyTime != "" {
+		lastModifyTime = utils.GormDateStrToDateTimeStr(lastModifyTime)
+	}
 	return
 }