1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package models
- import (
- "eta/eta_index_lib/global"
- "eta/eta_index_lib/utils"
- "time"
- )
- type BaseFromRzdIndex struct {
- BaseFromRzdIndexId int `gorm:"column:base_from_rzd_index_id;type:int(11);primaryKey;not null;"`
- CreateTime time.Time `gorm:"column:create_time;type:datetime;comment:创建时间;not null;default:CURRENT_TIMESTAMP;"`
- ModifyTime time.Time `gorm:"column:modify_time;type:datetime;comment:修改时间;not null;default:CURRENT_TIMESTAMP;"`
- BaseFromRzdClassifyId int `gorm:"column:base_from_rzd_classify_id;type:int(11) UNSIGNED;comment:原始数据指标分类id;not null;default:0;"`
- IndexCode string `gorm:"column:index_code;type:varchar(255);comment:指标编码;"`
- IndexName string `gorm:"column:index_name;type:varchar(255);comment:指标名称;"`
- Frequency string `gorm:"column:frequency;type:varchar(20);comment:频度;"`
- Unit string `gorm:"column:unit;type:varchar(30);comment:单位;"`
- StartDate time.Time `gorm:"column:start_date;type:date;comment:数据开始日期;default:NULL;"`
- EndDate time.Time `gorm:"column:end_date;type:date;comment:数据结束日期;default:NULL;"`
- LatestValue float64 `gorm:"column:latest_value;type:double;comment:数据最新值;default:NULL;"`
- }
- func AddRzdIndexList(items []*BaseFromRzdIndex) (err error) {
-
-
- err = global.DEFAULT_DB.CreateInBatches(items, len(items)).Error
- return
- }
- func AddRzdIndex(item *BaseFromRzdIndex) (int64, error) {
-
-
- err := global.DEFAULT_DB.Create(&item).Error
- if err != nil {
- return 0, err
- }
- id := int64(item.BaseFromRzdIndexId)
- return id, nil
- }
- func GetRzdIndexByCode(indexCode string) (item *BaseFromRzdIndex, err error) {
-
- sql := `SELECT * FROM base_from_rzd_index WHERE index_code=?`
-
- err = global.DEFAULT_DB.Raw(sql, indexCode).First(&item).Error
- if utils.IsErrNoRow(err) {
- return nil, nil
- }
- return
- }
|