|
@@ -6,6 +6,7 @@ import (
|
|
|
"fmt"
|
|
|
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "gorm.io/gorm"
|
|
|
)
|
|
|
|
|
|
type GlClassify struct {
|
|
@@ -21,7 +22,7 @@ func GetGlSurveyClassify() (items []*GlClassify, err error) {
|
|
|
}
|
|
|
|
|
|
type GlFrequency struct {
|
|
|
- Frequency string `description:"频度:1-日度 2-周度 3-月度 4-季度 5-年度 99-无固定频率"`
|
|
|
+ Frequency string `description:"频度:1-日度 2-周度 3-月度 4-季度 5-年度 99-无固定频率" gorm:"column:FREQUENCY_NAME"`
|
|
|
}
|
|
|
|
|
|
func GetGlFrequencyByClassifyId(breedShortName string) (items []*GlFrequency, err error) {
|
|
@@ -41,11 +42,20 @@ func GetGlFrequencyByClassifyId(breedShortName string) (items []*GlFrequency, er
|
|
|
|
|
|
type GlIndex struct {
|
|
|
Id int `gorm:"column:id;primaryKey"`
|
|
|
- IndexCode string `description:"指标编码"`
|
|
|
- IndexName string `description:"指标名称"`
|
|
|
- UnitName string `description:"单位"`
|
|
|
- FrequencyName string `description:"频度名称"`
|
|
|
- UpdateTime string `description:"更新时间"`
|
|
|
+ IndexCode string `description:"指标编码" gorm:"column:INDEX_CODE"`
|
|
|
+ IndexName string `description:"指标名称" gorm:"column:INDEX_NAME"`
|
|
|
+ UnitName string `description:"单位" gorm:"column:UNIT_NAME"`
|
|
|
+ FrequencyName string `description:"频度名称" gorm:"column:FREQUENCY_NAME"`
|
|
|
+ UpdateTime string `description:"更新时间" gorm:"column:UPDATE_TIME"`
|
|
|
+}
|
|
|
+
|
|
|
+func (g *GlIndex) AfterFind(tx *gorm.DB) (err error) {
|
|
|
+ g.UpdateTime = utils.GormDateStrToDateTimeStr(g.UpdateTime)
|
|
|
+ return
|
|
|
+}
|
|
|
+func (g *GlIndex) TimeToDateStr() {
|
|
|
+ g.UpdateTime = utils.GormDateStrToDateTimeStr(g.UpdateTime)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func GetGlIndex(breedShortName, frequency string) (items []*GlIndex, err error) {
|
|
@@ -83,8 +93,13 @@ type GlIndexList struct {
|
|
|
}
|
|
|
|
|
|
type GlIndexData struct {
|
|
|
- InputValue string `description:"日期"`
|
|
|
- DataTime string `description:"值"`
|
|
|
+ InputValue string `description:"日期" gorm:"column:DATA_DATE"`
|
|
|
+ DataValue string `description:"值" gorm:"column:DATA_VALUE"`
|
|
|
+}
|
|
|
+
|
|
|
+func (g *GlIndexData) AfterFind(tx *gorm.DB) (err error) {
|
|
|
+ g.InputValue = utils.GormDateStrToDateStr(g.InputValue)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func GetGlIndexData(indexCode string, startSize, pageSize int) (items []*GlIndexData, err error) {
|
|
@@ -104,6 +119,10 @@ func GetGlIndexByCode(indexCode string) (items *GlIndex, err error) {
|
|
|
sql := `SELECT * FROM mb_index_main_info WHERE INDEX_CODE=?`
|
|
|
o := global.DbMap[utils.DbNameGL]
|
|
|
err = o.Raw(sql, indexCode).First(&items).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items.TimeToDateStr()
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -123,21 +142,30 @@ func GetGlIndexDataCount(indexCode string) (count int, err error) {
|
|
|
}
|
|
|
|
|
|
type GlSearchIndex struct {
|
|
|
- Id int `orm:"column(ID)"`
|
|
|
- IndexCode string `orm:"column(INDEX_CODE)"`
|
|
|
- IndexName string `orm:"column(INDEX_NAME)"`
|
|
|
- UnitName string `orm:"column(UNIT_NAME)"`
|
|
|
- FrequencyName string `orm:"column(FREQUENCY_NAME)"`
|
|
|
- UpdateTime string `orm:"column(UPDATE_TIME)"`
|
|
|
- BreedShortName string `orm:"column(BREED_SHORT_NAME)"`
|
|
|
- StartDate string `orm:"column(BEGIN_DATE)"`
|
|
|
- EndDate string `orm:"column(END_DATE)"`
|
|
|
- LatestValue float64 `orm:"column(DATA_VALUE)"`
|
|
|
- CreateTime string `orm:"column(CREATE_TIME)"`
|
|
|
- ModifyTime string `orm:"column(UPDATE_TIME)"`
|
|
|
- Source int
|
|
|
- SourceName string
|
|
|
- SearchText string `description:"搜索结果(含高亮)"`
|
|
|
+ Id int `orm:"column(ID)" gorm:"column:ID"`
|
|
|
+ IndexCode string `orm:"column(INDEX_CODE)" gorm:"column:INDEX_CODE"`
|
|
|
+ IndexName string `orm:"column(INDEX_NAME)" gorm:"column:INDEX_NAME"`
|
|
|
+ UnitName string `orm:"column(UNIT_NAME)" gorm:"column:UNIT_NAME"`
|
|
|
+ FrequencyName string `orm:"column(FREQUENCY_NAME)" gorm:"column:FREQUENCY_NAME"`
|
|
|
+ UpdateTime string `orm:"column(UPDATE_TIME)" gorm:"column:UPDATE_TIME"`
|
|
|
+ BreedShortName string `orm:"column(BREED_SHORT_NAME)" gorm:"column:BREED_SHORT_NAME"`
|
|
|
+ StartDate string `orm:"column(BEGIN_DATE)" gorm:"column:BEGIN_DATE"`
|
|
|
+ EndDate string `orm:"column(END_DATE)" gorm:"column:END_DATE"`
|
|
|
+ LatestValue float64 `orm:"column(DATA_VALUE)" gorm:"column:DATA_VALUE"`
|
|
|
+ CreateTime string `orm:"column(CREATE_TIME)" gorm:"column:CREATE_TIME"`
|
|
|
+ ModifyTime string `orm:"column(UPDATE_TIME)" gorm:"column:UPDATE_TIME"`
|
|
|
+ Source int `gorm:"-"`
|
|
|
+ SourceName string `orm:"column(SOURCE_NAME)" gorm:"column:SOURCE_NAME"`
|
|
|
+ SearchText string `description:"搜索结果(含高亮)" gorm:"-"`
|
|
|
+}
|
|
|
+
|
|
|
+func (g *GlSearchIndex) AfterFind(tx *gorm.DB) (err error) {
|
|
|
+ g.UpdateTime = utils.GormDateStrToDateTimeStr(g.UpdateTime)
|
|
|
+ g.CreateTime = utils.GormDateStrToDateTimeStr(g.CreateTime)
|
|
|
+ g.ModifyTime = utils.GormDateStrToDateTimeStr(g.ModifyTime)
|
|
|
+ g.StartDate = utils.GormDateStrToDateStr(g.StartDate)
|
|
|
+ g.EndDate = utils.GormDateStrToDateStr(g.EndDate)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func GetGlItemList(keyword string) (items []*GlSearchIndex, err error) {
|