@@ -99,7 +99,7 @@ func GetChartEdbMappingListByEdbInfoIdList(edbIdList []int) (list []*ChartEdbInf
sql := ` SELECT edb_info_id,source_name,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value,edb_type
FROM edb_info
WHERE edb_info_id IN ?
- ORDER BY FIELD(edb_info_id,` + utils.GetOrmInReplace(num) + `)
+ ORDER BY FIELD(edb_info_id,` + utils.GetNumOrmInReplace(num) + `)
`
//_, err = o.Raw(sql, edbIdList, edbIdList).QueryRows(&list)
var pars []interface{}
@@ -3,6 +3,7 @@ package future_good
import (
"eta/eta_chart_lib/global"
"eta/eta_chart_lib/utils"
+ "gorm.io/gorm"
"time"
)
@@ -31,6 +32,14 @@ type FutureGoodEdbInfo struct {
ModifyTime time.Time
}
+// AfterFind 在该模型上设置钩子函数,把日期转成正确的string,所以查询函数只能用Find或者First函数,Scan是不会触发该函数的来获取数据
+func (m *FutureGoodEdbInfo) AfterFind(db *gorm.DB) (err error) {
+ m.StartDate = utils.GormDateStrToDateStr(m.StartDate)
+ m.EndDate = utils.GormDateStrToDateStr(m.EndDate)
+
+ return
+}
// GetFutureGoodEdbInfo 期货指标
func GetFutureGoodEdbInfo(edbInfoId int) (item *FutureGoodEdbInfo, err error) {
//o := orm.NewOrmUsingDB("data")
@@ -647,6 +647,20 @@ func GetOrmInReplace(num int) string {
return "?"
+// GetNumOrmInReplace
+// @Description: 获取orm的in查询替换?的方法(这个是真的要返回N个?,用来做排序使用)
+// @author: Roc
+// @datetime 2025-03-19 13:43:12
+// @param num int
+// @return string
+func GetNumOrmInReplace(num int) string {
+ template := make([]string, num)
+ for i := 0; i < num; i++ {
+ template[i] = "?"
+ }
+ return strings.Join(template, ",")
// RevSlice 反转切片
func RevSlice(slice []int) []int {
for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {