package data_manage import ( "fmt" "github.com/beego/beego/v2/client/orm" "strings" "time" ) // AiPredictModelIndex AI预测模型标的 type AiPredictModelIndex struct { AiPredictModelIndexId int `orm:"column(ai_predict_model_index_id);pk"` IndexName string `description:"标的名称"` IndexCode string `description:"自生成的指标编码"` ClassifyId int `description:"分类ID"` ModelFramework string `description:"模型框架"` PredictDate time.Time `description:"预测日期"` PredictValue float64 `description:"预测值"` PredictFrequency string `description:"预测频度"` DirectionAccuracy string `description:"方向准确度"` AbsoluteDeviation string `description:"绝对偏差"` ExtraConfig string `description:"模型参数"` Sort int `description:"排序"` SysUserId int `description:"创建人ID"` SysUserRealName string `description:"创建人姓名"` LeftMin string `description:"图表左侧最小值"` LeftMax string `description:"图表左侧最大值"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` } func (m *AiPredictModelIndex) TableName() string { return "ai_predict_model_index" } type AiPredictModelIndexCols struct { PrimaryId string IndexName string IndexCode string ClassifyId string ModelFramework string PredictDate string PredictValue string DirectionAccuracy string AbsoluteDeviation string ExtraConfig string Sort string SysUserId string SysUserRealName string LeftMin string LeftMax string CreateTime string ModifyTime string } func (m *AiPredictModelIndex) Cols() AiPredictModelIndexCols { return AiPredictModelIndexCols{ PrimaryId: "ai_predict_model_index_id", IndexName: "index_name", IndexCode: "index_code", ClassifyId: "classify_id", ModelFramework: "model_framework", PredictDate: "predict_date", PredictValue: "predict_value", DirectionAccuracy: "direction_accuracy", AbsoluteDeviation: "absolute_deviation", ExtraConfig: "extra_config", Sort: "sort", SysUserId: "sys_user_id", SysUserRealName: "sys_user_real_name", LeftMin: "left_min", LeftMax: "left_max", CreateTime: "create_time", ModifyTime: "modify_time", } } func (m *AiPredictModelIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelIndex, err error) { o := orm.NewOrmUsingDB("data") fields := strings.Join(fieldArr, ",") if len(fieldArr) == 0 { fields = `*` } order := fmt.Sprintf(`ORDER BY %s DESC`, m.Cols().CreateTime) if orderRule != "" { order = ` ORDER BY ` + orderRule } sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order) _, err = o.Raw(sql, pars).QueryRows(&items) return }