|
@@ -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 ?,? `
|