edb_info.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type EdbInfo struct {
  7. EdbInfoId int `orm:"column(edb_info_id);pk"`
  8. EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"`
  9. SourceName string `description:"来源名称"`
  10. Source int `description:"来源id"`
  11. EdbCode string `description:"指标编码"`
  12. EdbName string `description:"指标名称"`
  13. EdbNameEn string `description:"英文指标名称"`
  14. EdbNameSource string `description:"指标名称来源"`
  15. Frequency string `description:"频率"`
  16. Unit string `description:"单位"`
  17. UnitEn string `description:"英文单位"`
  18. StartDate string `description:"起始日期"`
  19. EndDate string `description:"终止日期"`
  20. ClassifyId int `description:"分类id"`
  21. SysUserId int
  22. SysUserRealName string
  23. UniqueCode string `description:"指标唯一编码"`
  24. CreateTime time.Time
  25. ModifyTime time.Time
  26. MinValue float64 `description:"指标最小值"`
  27. MaxValue float64 `description:"指标最大值"`
  28. CalculateFormula string `description:"计算公式"`
  29. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  30. IsUpdate int `description:"当天是否已更新,1:未更新,2:已更新"`
  31. Sort int `description:"排序字段"`
  32. LatestDate string `description:"数据最新日期"`
  33. LatestValue float64 `description:"数据最新值"`
  34. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  35. MoveFrequency string `description:"移动频度"`
  36. NoUpdate int8 `description:"是否停止更新,0:继续更新;1:停止更新"`
  37. ServerUrl string `description:"服务器地址"`
  38. ChartImage string `description:"图表图片"`
  39. Calendar string `description:"公历/农历" orm:"default(公历);"`
  40. DataDateType string `orm:"column(data_date_type);size(255);null;default(交易日)"`
  41. }
  42. type EdbInfoView struct {
  43. EdbInfoId int `orm:"column(edb_info_id);pk"`
  44. EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"`
  45. SourceName string `description:"来源名称"`
  46. Source int `description:"来源id"`
  47. EdbCode string `description:"指标编码"`
  48. EdbName string `description:"指标名称"`
  49. EdbNameEn string `description:"英文指标名称"`
  50. EdbNameSource string `description:"指标名称来源"`
  51. Frequency string `description:"频率"`
  52. Unit string `description:"单位"`
  53. UnitEn string `description:"英文单位"`
  54. StartDate string `description:"起始日期"`
  55. EndDate string `description:"终止日期"`
  56. ClassifyId int `description:"分类id"`
  57. SysUserId int
  58. SysUserRealName string
  59. UniqueCode string `description:"指标唯一编码"`
  60. CreateTime time.Time
  61. ModifyTime time.Time
  62. MinValue float64 `description:"指标最小值"`
  63. MaxValue float64 `description:"指标最大值"`
  64. CalculateFormula string `description:"计算公式"`
  65. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  66. Sort int `description:"排序字段"`
  67. LatestDate string `description:"数据最新日期"`
  68. LatestValue float64 `description:"数据最新值"`
  69. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  70. MoveFrequency string `description:"移动频度"`
  71. NoUpdate int8 `description:"是否停止更新,0:继续更新;1:停止更新"`
  72. ServerUrl string `description:"服务器地址"`
  73. ChartImage string `description:"图表图片"`
  74. Calendar string `description:"公历/农历" orm:"default(公历);"`
  75. DataDateType string `orm:"column(data_date_type);size(255);null;default(交易日)"`
  76. CalculateList []*EdbInfoCalculateMappingDetail
  77. }
  78. func GetEdbInfoByEdbCode(edbCode string) (item *EdbInfoView, err error) {
  79. o := orm.NewOrm()
  80. sql := ` SELECT * FROM edb_info WHERE edb_code=? `
  81. err = o.Raw(sql, edbCode).QueryRow(&item)
  82. return
  83. }
  84. type EdbInfoDetailReq struct {
  85. EdbCode string `description:"指标编码"`
  86. }
  87. type EdbInfoCalculateMappingDetail struct {
  88. EdbCode string `description:"指标编码"`
  89. BaseEdbInfoCode []*EdbInfoCalculateBaseEdbInfo `description:"依赖的基础指标编码"`
  90. }
  91. func GetEdbInfoCalculateMapping(edbCode string) (items []*EdbInfoCalculateMappingDetail, err error) {
  92. o := orm.NewOrm()
  93. sql := ` SELECT edb_code FROM edb_info_calculate_mapping AS a
  94. WHERE a.from_edb_code=?
  95. ORDER BY a.edb_info_calculate_mapping_id ASC `
  96. _, err = o.Raw(sql, edbCode).QueryRows(&items)
  97. return
  98. }
  99. type EdbInfoCalculateBaseEdbInfo struct {
  100. FromEdbCode string `description:"指标编码"`
  101. }
  102. func GetEdbInfoCalculateBaseEdbInfo(edbCode string) (items []*EdbInfoCalculateBaseEdbInfo, err error) {
  103. o := orm.NewOrm()
  104. sql := ` SELECT a.from_edb_code FROM edb_info_calculate_mapping AS a
  105. WHERE a.edb_code=?
  106. ORDER BY a.edb_info_calculate_mapping_id ASC `
  107. _, err = o.Raw(sql, edbCode).QueryRows(&items)
  108. return
  109. }
  110. func GetEdbInfoItemByEdbCode(edbCode string) (item *EdbInfo, err error) {
  111. o := orm.NewOrm()
  112. sql := ` SELECT * FROM edb_info WHERE edb_code=? `
  113. err = o.Raw(sql, edbCode).QueryRow(&item)
  114. return
  115. }