ai_predict_model_index.go 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "strings"
  6. "time"
  7. )
  8. // AiPredictModelIndex AI预测模型标的
  9. type AiPredictModelIndex struct {
  10. AiPredictModelIndexId int `orm:"column(ai_predict_model_index_id);pk"`
  11. IndexName string `description:"标的名称"`
  12. IndexCode string `description:"自生成的指标编码"`
  13. ClassifyId int `description:"分类ID"`
  14. ModelFramework string `description:"模型框架"`
  15. PredictDate time.Time `description:"预测日期"`
  16. PredictValue float64 `description:"预测值"`
  17. PredictFrequency string `description:"预测频度"`
  18. DirectionAccuracy string `description:"方向准确度"`
  19. AbsoluteDeviation string `description:"绝对偏差"`
  20. ExtraConfig string `description:"模型参数"`
  21. Sort int `description:"排序"`
  22. SysUserId int `description:"创建人ID"`
  23. SysUserRealName string `description:"创建人姓名"`
  24. LeftMin string `description:"图表左侧最小值"`
  25. LeftMax string `description:"图表左侧最大值"`
  26. CreateTime time.Time `description:"创建时间"`
  27. ModifyTime time.Time `description:"修改时间"`
  28. }
  29. func (m *AiPredictModelIndex) TableName() string {
  30. return "ai_predict_model_index"
  31. }
  32. type AiPredictModelIndexCols struct {
  33. PrimaryId string
  34. IndexName string
  35. IndexCode string
  36. ClassifyId string
  37. ModelFramework string
  38. PredictDate string
  39. PredictValue string
  40. DirectionAccuracy string
  41. AbsoluteDeviation string
  42. ExtraConfig string
  43. Sort string
  44. SysUserId string
  45. SysUserRealName string
  46. LeftMin string
  47. LeftMax string
  48. CreateTime string
  49. ModifyTime string
  50. }
  51. func (m *AiPredictModelIndex) Cols() AiPredictModelIndexCols {
  52. return AiPredictModelIndexCols{
  53. PrimaryId: "ai_predict_model_index_id",
  54. IndexName: "index_name",
  55. IndexCode: "index_code",
  56. ClassifyId: "classify_id",
  57. ModelFramework: "model_framework",
  58. PredictDate: "predict_date",
  59. PredictValue: "predict_value",
  60. DirectionAccuracy: "direction_accuracy",
  61. AbsoluteDeviation: "absolute_deviation",
  62. ExtraConfig: "extra_config",
  63. Sort: "sort",
  64. SysUserId: "sys_user_id",
  65. SysUserRealName: "sys_user_real_name",
  66. LeftMin: "left_min",
  67. LeftMax: "left_max",
  68. CreateTime: "create_time",
  69. ModifyTime: "modify_time",
  70. }
  71. }
  72. func (m *AiPredictModelIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*AiPredictModelIndex, err error) {
  73. o := orm.NewOrmUsingDB("data")
  74. fields := strings.Join(fieldArr, ",")
  75. if len(fieldArr) == 0 {
  76. fields = `*`
  77. }
  78. order := fmt.Sprintf(`ORDER BY %s DESC`, m.Cols().CreateTime)
  79. if orderRule != "" {
  80. order = ` ORDER BY ` + orderRule
  81. }
  82. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  83. _, err = o.Raw(sql, pars).QueryRows(&items)
  84. return
  85. }