Selaa lähdekoodia

Merge branch 'dm' of http://8.136.199.33:3000/eta_server/eta_api into dm

xyxie 1 kuukausi sitten
vanhempi
commit
ec622f7dc3

+ 3 - 3
models/data_manage/base_from_smm.go

@@ -386,9 +386,9 @@ type BaseFromSmmIndexItem 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

+ 15 - 0
models/data_manage/coal_data.go

@@ -4,6 +4,7 @@ import (
 	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"fmt"
+	"gorm.io/gorm"
 )
 
 type BaseFromCoalmineMapping struct {
@@ -87,6 +88,20 @@ type BaseFromCoalmineIndex struct {
 	ModifyTime                     string `description:"修改时间"`
 }
 
+func (m *BaseFromCoalmineIndex) AfterFind(db *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if m.CreateTime != "" {
+			m.CreateTime = utils.GormDateStrToDateTimeStr(m.CreateTime)
+		}
+		if m.ModifyTime != "" {
+			m.ModifyTime = utils.GormDateStrToDateTimeStr(m.ModifyTime)
+		}
+		if m.DataTime != "" {
+			m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
+		}
+	}
+	return
+}
 func GetBaseFromCoalIndexByCode(suffix, indexCode string) (items []*BaseFromCoalmineIndex, err error) {
 	o := global.DbMap[utils.DbNameIndex]
 	sql := `SELECT * FROM base_from_coalmine_%s WHERE index_code=? ORDER BY data_time DESC`

+ 1 - 1
models/data_manage/future_good/future_good_edb_info.go

@@ -148,8 +148,8 @@ func GetFutureGoodEdbExchangeList(condition string, pars []interface{}) (list []
 		sql += condition
 	}
 	sql += ` GROUP BY exchange `
+	sql = utils.ReplaceDriverKeywords("", sql)
 	err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Scan(&list).Error
-
 	return
 }
 

+ 16 - 0
models/data_manage/future_good/future_good_edb_info_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"
 )
 
@@ -54,6 +55,21 @@ type FutureGoodEdbDataItem struct {
 	CreateTime          string
 }
 
+func (m *FutureGoodEdbDataItem) AfterFind(db *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if m.CreateTime != "" {
+			m.CreateTime = utils.GormDateStrToDateTimeStr(m.CreateTime)
+		}
+		if m.ModifyTime != "" {
+			m.ModifyTime = utils.GormDateStrToDateTimeStr(m.ModifyTime)
+		}
+		if m.DataTime != "" {
+			m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
+		}
+	}
+	return
+}
+
 // GetFutureGoodEdbDataListCount 获取期货指标数据汇总数
 func GetFutureGoodEdbDataListCount(condition string, pars []interface{}) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM future_good_edb_data WHERE 1=1 `

+ 1 - 1
models/data_manage/gl_data.go

@@ -9,7 +9,7 @@ import (
 )
 
 type GlClassify struct {
-	BreedShortName string `orm:"column(BREED_SHORT_NAME)" description:"分类名称"`
+	BreedShortName string `gorm:"column:BREED_SHORT_NAME" description:"分类名称"`
 }
 
 func GetGlSurveyClassify() (items []*GlClassify, err error) {

+ 23 - 13
models/data_manage/lz_data.go

@@ -1,6 +1,7 @@
 package data_manage
 
 import (
+	"gorm.io/gorm"
 	"time"
 
 	"eta/eta_api/global"
@@ -69,19 +70,19 @@ func GetLongzhongSurveyProduct(breedId, frequency int) (items []*LongzhongSurvey
 }
 
 type LzProductList struct {
-	SurveyProductId int             `gorm:"column:survey_product_id;primaryKey"`
-	BreedName       string          `gorm:"column:breed_name" description:"品种名称"`
-	QuotaName       string          `gorm:"column:quota_name" description:"指标名称"`
-	UnitName        string          `gorm:"column:unit_name" description:"单位"`
-	SampleType      int64           `gorm:"column:sample_type" description:"样本类型 0-空 1-企业 2-港口 3-运距 4-区域/国家 99-不确定"`
-	SampleName      string          `gorm:"column:sample_name" description:"样本名称"`
-	Device          string          `gorm:"column:device" description:"设备"`
-	Frequency       int64           `gorm:"column:frequency" description:"频度"`
-	Custom          string          `gorm:"column:custom" description:"扩展字段"`
-	StartDate       string          `gorm:"column:start_date" description:"开始日期"`
-	EndDate         string          `gorm:"column:end_date" description:"结束日期"`
-	ModifyTime      string          `gorm:"column:modify_time" description:"修改时间"`
-	LzCode          string          `gorm:"column:lz_code" description:"指标编码"`
+	SurveyProductId int              `gorm:"column:survey_product_id;primaryKey"`
+	BreedName       string           `gorm:"column:breed_name" description:"品种名称"`
+	QuotaName       string           `gorm:"column:quota_name" description:"指标名称"`
+	UnitName        string           `gorm:"column:unit_name" description:"单位"`
+	SampleType      int64            `gorm:"column:sample_type" description:"样本类型 0-空 1-企业 2-港口 3-运距 4-区域/国家 99-不确定"`
+	SampleName      string           `gorm:"column:sample_name" description:"样本名称"`
+	Device          string           `gorm:"column:device" description:"设备"`
+	Frequency       int64            `gorm:"column:frequency" description:"频度"`
+	Custom          string           `gorm:"column:custom" description:"扩展字段"`
+	StartDate       string           `gorm:"column:start_date" description:"开始日期"`
+	EndDate         string           `gorm:"column:end_date" description:"结束日期"`
+	ModifyTime      string           `gorm:"column:modify_time" description:"修改时间"`
+	LzCode          string           `gorm:"column:lz_code" description:"指标编码"`
 	DataList        []*LzProductData `gorm:"-"`
 }
 
@@ -90,6 +91,15 @@ type LzProductData struct {
 	DataTime   string `description:"值"`
 }
 
+func (m *LzProductData) AfterFind(db *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if m.DataTime != "" {
+			m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
+		}
+	}
+	return
+}
+
 func GetLongzhongSurveyProductData(surveyProductId int) (items []*LzProductData, err error) {
 	sql := `SELECT * FROM longzhong_survey_data WHERE survey_product_id=? ORDER BY data_time DESC`
 	o := global.DbMap[utils.DbNameManualIndex]