|
@@ -26,6 +26,11 @@ func GetTargetByTradeCode(tradeCode string) (item *EdbInfoItem, err error) {
|
|
|
sql := `SELECT * FROM edbinfo WHERE TRADE_CODE = ? `
|
|
|
o := global.DbMap[utils.DbNameManualIndex]
|
|
|
err = o.Raw(sql, tradeCode).First(&item).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item.ConvDate()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -186,7 +191,7 @@ func GetCountEdbInfoList(condition string, pars []interface{}) (total int, err e
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += ` ORDER BY a.create_date DESC `
|
|
|
- err = o.Raw(sql, pars...).First(&total).Error
|
|
|
+ err = o.Raw(sql, pars...).Scan(&total).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -371,6 +376,13 @@ type EdbinfoOpRecordItem struct {
|
|
|
CreateTime string `gorm:"column:create_time" description:"创建时间"`
|
|
|
}
|
|
|
|
|
|
+// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find函数,First或者Scan是不会触发该函数的来获取数据
|
|
|
+func (m *EdbinfoOpRecordItem) AfterFind(db *gorm.DB) (err error) {
|
|
|
+ m.CreateTime = utils.GormDateStrToDateTimeStr(m.CreateTime)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// EdbinfoOpRecordListResp 指标数据结构体
|
|
|
type EdbinfoOpRecordListResp struct {
|
|
|
List []*EdbinfoOpRecordItem
|