Browse Source

批量修改

kobe6258 2 months ago
parent
commit
7974d0ed34

+ 4 - 2
models/data_manage/baiinfo_data.go

@@ -5,6 +5,7 @@ import (
 	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"github.com/shopspring/decimal"
 	"gorm.io/gorm"
 )
 
@@ -137,8 +138,8 @@ type BaiinfoIndexList struct {
 }
 
 type BaiinfoIndexData struct {
-	Value    string `orm:"column(value)" description:"日期"`
-	DataTime string `orm:"column(data_time)" description:"值"`
+	Value    decimal.Decimal `gorm:"column:value" description:"日期"`
+	DataTime string          `gorm:"column:data_time" description:"值"`
 }
 
 func (obj *BaiinfoIndexData) AfterFind(tx *gorm.DB) (err error) {
@@ -147,6 +148,7 @@ func (obj *BaiinfoIndexData) AfterFind(tx *gorm.DB) (err error) {
 			obj.DataTime = utils.GormDateStrToDateStr(obj.DataTime)
 		}
 	}
+
 	return
 }
 func GetBaiinfoIndexData(indexCode string, startSize, pageSize int) (items []*BaiinfoIndexData, err error) {

+ 30 - 4
models/data_manage/base_from_smm.go

@@ -61,15 +61,15 @@ func GetBaseFromSmmBySmmCode(smmCode string) (item *BaseFromSmm, err error) {
 }
 
 type BaseFromSmmIndex struct {
-	BaseFromSmmIndexId int `orm:"column(base_from_smm_index_id);pk" gorm:"primaryKey"`
+	BaseFromSmmIndexId int `gorm:"column:base_from_smm_index_id;primaryKey"`
 	ClassifyId         int
 	Interface          string
 	Name               string
 	IndexCode          string
 	IndexName          string
-	Type1              string `orm:"column(type_1)"`
-	Type2              string `orm:"column(type_2)"`
-	Type3              string `orm:"column(type_3)"`
+	Type1              string `gorm:"column:type_1"`
+	Type2              string `gorm:"column:type_2"`
+	Type3              string `gorm:"column:type_3"`
 	Frequency          string
 	Unit               string
 	ApiStartTime       string
@@ -87,6 +87,32 @@ type BaseFromSmmIndex struct {
 	TerminalCode       string `description:"终端编码"`
 }
 
+func (m *BaseFromSmmIndex) AfterFind(tx *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if m.ApiStartTime != "" {
+			m.ApiStartTime = utils.GormDateStrToDateTimeStr(m.ApiStartTime)
+		}
+		if m.ApiUpdateTime != "" {
+			m.ApiUpdateTime = utils.GormDateStrToDateTimeStr(m.ApiUpdateTime)
+		}
+		if m.StartTime != "" {
+			m.StartTime = utils.GormDateStrToDateTimeStr(m.StartTime)
+		}
+		if m.FinishTime != "" {
+			m.FinishTime = utils.GormDateStrToDateTimeStr(m.FinishTime)
+		}
+		if m.ReleaseTime != "" {
+			m.ReleaseTime = utils.GormDateStrToDateTimeStr(m.ReleaseTime)
+		}
+		if m.StartDate != "" {
+			m.StartDate = utils.GormDateStrToDateStr(m.StartDate)
+		}
+		if m.EndDate != "" {
+			m.EndDate = utils.GormDateStrToDateStr(m.EndDate)
+		}
+	}
+	return
+}
 func AddBaseFromSmmIndex(item *BaseFromSmmIndex) (lastId int64, err error) {
 	o := global.DbMap[utils.DbNameIndex]
 	err = o.Create(item).Error

+ 43 - 10
models/data_manage/smm_data.go

@@ -4,6 +4,7 @@ import (
 	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"gorm.io/gorm"
 	"time"
 )
 
@@ -32,14 +33,14 @@ func GetSmmFrequencyByClassifyId(classifyId int) (items []*GlFrequency, err erro
 }
 
 type SmmIndex struct {
-	BaseFromSmmIndexId int `orm:"column(base_from_smm_index_id);pk" gorm:"primaryKey"`
+	BaseFromSmmIndexId int `gorm:"column:base_from_smm_index_id;primaryKey"`
 	Interface          string
 	Name               string
 	IndexCode          string
 	IndexName          string
-	Type1              string `orm:"column(type_1)"`
-	Type2              string `orm:"column(type_2)"`
-	Type3              string `orm:"column(type_3)"`
+	Type1              string `gorm:"column:type_1"`
+	Type2              string `gorm:"column:type_2"`
+	Type3              string `gorm:"column:type_3"`
 	Frequency          string
 	Unit               string
 	ApiStartTime       string
@@ -52,6 +53,30 @@ type SmmIndex struct {
 	EndValue           float64 `description:"指标的最新值"`
 }
 
+func (obj *SmmIndex) 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.StartTime != "" {
+			obj.StartTime = utils.GormDateStrToDateTimeStr(obj.StartTime)
+		}
+		if obj.FinishTime != "" {
+			obj.FinishTime = utils.GormDateStrToDateTimeStr(obj.FinishTime)
+		}
+		if obj.ApiStartTime != "" {
+			obj.ApiStartTime = utils.GormDateStrToDateTimeStr(obj.ApiStartTime)
+		}
+		if obj.ApiUpdateTime != "" {
+			obj.ApiUpdateTime = utils.GormDateStrToDateTimeStr(obj.ApiUpdateTime)
+		}
+	}
+	return
+}
+
 type SmmIndexItem struct {
 	BaseFromSmmIndexId int `orm:"column(base_from_smm_index_id);pk" gorm:"primaryKey"`
 	ClassifyId         int
@@ -60,9 +85,9 @@ type SmmIndexItem struct {
 	Name               string
 	IndexCode          string
 	IndexName          string
-	Type1              string `orm:"column(type_1)"`
-	Type2              string `orm:"column(type_2)"`
-	Type3              string `orm:"column(type_3)"`
+	Type1              string `gorm:"column:type_1"`
+	Type2              string `gorm:"column:type_2"`
+	Type3              string `gorm:"column:type_3"`
 	Frequency          string
 	Unit               string
 	ApiStartTime       string
@@ -138,7 +163,7 @@ func GetSmmFrequencyByCode(code string) (items []*string, err error) {
 }
 
 type SmmIndexList struct {
-	BaseFromSmmIndexId int `orm:"column(base_from_smm_index_id);pk" gorm:"primaryKey"`
+	BaseFromSmmIndexId int `gorm:"column:base_from_smm_index_id);primaryKey"`
 	Interface          string
 	Name               string
 	IndexCode          string
@@ -158,10 +183,18 @@ type SmmIndexList struct {
 }
 
 type SmmIndexData struct {
-	Value    string `orm:"column(value)" description:"日期"`
-	DataTime string `orm:"column(data_time)" description:"值"`
+	Value    string `gorm:"column:value" description:"日期"`
+	DataTime string `gorm:"column:data_time" description:"值"`
 }
 
+func (m *SmmIndexData) AfterFind(tx *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if m.DataTime != "" {
+			m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
+		}
+	}
+	return
+}
 func GetSmmIndexData(indexCode string, startSize, pageSize int) (items []*SmmIndexData, err error) {
 	o := global.DbMap[utils.DbNameIndex]
 	sql := ` SELECT *  FROM base_from_smm_data WHERE index_code=? ORDER BY data_time DESC LIMIT ?,? `

+ 9 - 0
models/data_source/longzhong.go

@@ -4,6 +4,7 @@ import (
 	"eta/eta_api/global"
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/utils"
+	"gorm.io/gorm"
 	"time"
 )
 
@@ -156,6 +157,14 @@ type LongzhongSurveyData struct {
 	DataTime             string
 }
 
+func (obj *LongzhongSurveyData) AfterFind(tx *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if obj.DataTime != "" {
+			obj.DataTime = utils.GormDateStrToDateStr(obj.DataTime)
+		}
+	}
+	return
+}
 func GetLongzhongSurveyDataById(lzInfoId int) (items []*LongzhongSurveyData, err error) {
 	o := global.DbMap[utils.DbNameManualIndex]
 	sql := `SELECT * FROM longzhong_survey_data WHERE survey_product_id=? ORDER BY data_time DESC `

+ 11 - 0
models/target.go

@@ -1314,6 +1314,17 @@ type LongzhongSurveyProduct struct {
 	LzCode               string
 }
 
+func (obj *LongzhongSurveyProduct) AfterFind(tx *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if obj.StartDate != "" {
+			obj.StartDate = utils.GormDateStrToDateStr(obj.StartDate)
+		}
+		if obj.EndDate != "" {
+			obj.EndDate = utils.GormDateStrToDateStr(obj.EndDate)
+		}
+	}
+	return
+}
 func GetLongzhongSurveyProductByClassifyName(productName string) (items []*LongzhongSurveyProduct, err error) {
 	sql := `SELECT * FROM longzhong_survey_product WHERE breed_name=? ORDER BY survey_product_id ASC `
 	o := global.DbMap[utils.DbNameManualIndex]