|
@@ -69,11 +69,6 @@ type EdbInfo struct {
|
|
|
EndDateType int `description:"预测指标截止日期类型:0:未来日期,1未来期数"`
|
|
|
}
|
|
|
|
|
|
-func (e *EdbInfo) Add() (err error) {
|
|
|
- err = global.DEFAULT_DB.Create(e).Error
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find函数,First或者Scan是不会触发该函数的来获取数据
|
|
|
func (m *EdbInfo) AfterFind(db *gorm.DB) (err error) {
|
|
|
m.StartDate = utils.GormDateStrToDateStr(m.StartDate)
|
|
@@ -97,6 +92,11 @@ func (e *EdbInfo) ConvertDate() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func (e *EdbInfo) Add() (err error) {
|
|
|
+ err = global.DEFAULT_DB.Create(e).Error
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// AddEdbInfo 添加指标
|
|
|
func AddEdbInfo(item *EdbInfo) (lastId int64, err error) {
|
|
|
//o := orm.NewOrm()
|
|
@@ -168,6 +168,17 @@ type EdbInfoList struct {
|
|
|
//IsEnEdb bool `description:"是否展示英文标识"`
|
|
|
}
|
|
|
|
|
|
+// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find函数,First或者Scan是不会触发该函数的来获取数据
|
|
|
+func (e *EdbInfoList) AfterFind(db *gorm.DB) (err error) {
|
|
|
+ e.CreateTime = utils.GormDateStrToDateTimeStr(e.CreateTime)
|
|
|
+ e.ModifyTime = utils.GormDateStrToDateTimeStr(e.ModifyTime)
|
|
|
+ e.StartDate = utils.GormDateStrToDateStr(e.StartDate)
|
|
|
+ e.EndDate = utils.GormDateStrToDateStr(e.EndDate)
|
|
|
+ e.LatestDate = utils.GormDateStrToDateStr(e.LatestDate)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// ConvertDate
|
|
|
// @Description: 格式化EdbInfoList的日期
|
|
|
// @receiver e
|
|
@@ -531,22 +542,9 @@ type EdbInfoMaxAndMinInfo struct {
|
|
|
|
|
|
// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find函数,First或者Scan是不会触发该函数的来获取数据
|
|
|
func (m *EdbInfoMaxAndMinInfo) AfterFind(db *gorm.DB) (err error) {
|
|
|
- if m.MinDate != "" {
|
|
|
- minDateTmp, e := time.ParseInLocation(utils.FormatDateWallWithLoc, m.MinDate, time.Local)
|
|
|
- if e != nil {
|
|
|
- err = e
|
|
|
- return
|
|
|
- }
|
|
|
- m.MinDate = minDateTmp.Format(utils.FormatDate)
|
|
|
- }
|
|
|
- if m.MaxDate != "" {
|
|
|
- maxDateTmp, e := time.ParseInLocation(utils.FormatDateWallWithLoc, m.MaxDate, time.Local)
|
|
|
- if e != nil {
|
|
|
- err = e
|
|
|
- return
|
|
|
- }
|
|
|
- m.MaxDate = maxDateTmp.Format(utils.FormatDate)
|
|
|
- }
|
|
|
+ m.MinDate = utils.GormDateStrToDateStr(m.MinDate)
|
|
|
+ m.MaxDate = utils.GormDateStrToDateStr(m.MaxDate)
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -584,14 +582,8 @@ type EdbIndoDataUpdateTime struct {
|
|
|
|
|
|
// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find函数,First或者Scan是不会触发该函数的来获取数据
|
|
|
func (m *EdbIndoDataUpdateTime) AfterFind(db *gorm.DB) (err error) {
|
|
|
- if m.MinDate == "" {
|
|
|
- return
|
|
|
- }
|
|
|
- minDateTmp, err := time.ParseInLocation(utils.FormatDateWallWithLoc, m.MinDate, time.Local)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- m.MinDate = minDateTmp.Format(utils.FormatDate)
|
|
|
+ m.MinDate = utils.GormDateStrToDateStr(m.MinDate)
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -765,6 +757,13 @@ type EdbInfoSearchDataV1 struct {
|
|
|
Value string `description:"数据"`
|
|
|
}
|
|
|
|
|
|
+// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find函数,First或者Scan是不会触发该函数的来获取数据
|
|
|
+func (m *EdbInfoSearchDataV1) AfterFind(db *gorm.DB) (err error) {
|
|
|
+ m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// GetEdbDataListAllV1ByTo 通过事务链接获取数据列表
|
|
|
func GetEdbDataListAllV1ByTo(to *gorm.DB, condition string, pars []interface{}, source, subSource, order int) (items []*EdbInfoSearchDataV1, err error) {
|
|
|
sql := ``
|
|
@@ -1505,14 +1504,23 @@ type EdbInfoDetailResp struct {
|
|
|
UniqueCode string `description:"指标唯一编码"`
|
|
|
CreateTime time.Time
|
|
|
ModifyTime time.Time
|
|
|
- MinValue float64 `description:"指标最小值"`
|
|
|
- MaxValue float64 `description:"指标最大值"`
|
|
|
- EdbNameEn string `description:"英文指标名称"`
|
|
|
- UnitEn string `description:"英文单位"`
|
|
|
- LatestDate string `description:"数据最新日期"`
|
|
|
- LatestValue float64 `description:"数据最新值"`
|
|
|
- ChartImage string `description:"图表图片"`
|
|
|
- DataList []*EdbInfoSearchData
|
|
|
+ MinValue float64 `description:"指标最小值"`
|
|
|
+ MaxValue float64 `description:"指标最大值"`
|
|
|
+ EdbNameEn string `description:"英文指标名称"`
|
|
|
+ UnitEn string `description:"英文单位"`
|
|
|
+ LatestDate string `description:"数据最新日期"`
|
|
|
+ LatestValue float64 `description:"数据最新值"`
|
|
|
+ ChartImage string `description:"图表图片"`
|
|
|
+ DataList []*EdbInfoSearchData `gorm:"-"`
|
|
|
+}
|
|
|
+
|
|
|
+// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find函数,First或者Scan是不会触发该函数的来获取数据
|
|
|
+func (m *EdbInfoDetailResp) AfterFind(db *gorm.DB) (err error) {
|
|
|
+ m.StartDate = utils.GormDateStrToDateStr(m.StartDate)
|
|
|
+ m.EndDate = utils.GormDateStrToDateStr(m.EndDate)
|
|
|
+ m.LatestDate = utils.GormDateStrToDateStr(m.LatestDate)
|
|
|
+
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
type AddEdbInfoParams struct {
|