ai_predict_model_index.go 3.2 KB

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