future_good_edb_info.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package future_good
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // FutureGoodEdbInfo 期货指标表
  7. type FutureGoodEdbInfo struct {
  8. FutureGoodEdbInfoId int `orm:"column(future_good_edb_info_id);pk"`
  9. FutureGoodEdbCode string `description:"期货指标code"`
  10. FutureGoodEdbName string `description:"期货指标名称"`
  11. FutureGoodEdbNameEn string `description:"期货指标英文名称"`
  12. ParentId int `description:"上级期货id"`
  13. Exchange string `description:"所属交易所"`
  14. Month int `description:"所属月份"`
  15. StartDate string `description:"起始日期"`
  16. EndDate time.Time `description:"终止日期"`
  17. MinValue float64 `description:"最小值"`
  18. MaxValue float64 `description:"最大值"`
  19. LatestValue float64 `description:"数据最新的值"`
  20. LatestDate time.Time `description:"数据最新的日期"`
  21. ServerUrl string `description:"服务器地址"`
  22. CreateTime time.Time
  23. ModifyTime time.Time
  24. }
  25. // GetFutureGoodEdbInfo 期货指标
  26. func GetFutureGoodEdbInfo(edbInfoId int) (item *FutureGoodEdbInfo, err error) {
  27. o := orm.NewOrmUsingDB("data")
  28. sql := `SELECT * FROM future_good_edb_info WHERE future_good_edb_info_id = ? `
  29. sql += ` ORDER BY future_good_edb_info_id DESC `
  30. err = o.Raw(sql, edbInfoId).QueryRow(&item)
  31. return
  32. }
  33. // GetFutureGoodEdbInfoList 获取指标数据列表
  34. func GetFutureGoodEdbInfoList(condition string, pars []interface{}) (list []*FutureGoodEdbInfo, err error) {
  35. o := orm.NewOrmUsingDB("data")
  36. sql := `SELECT * FROM future_good_edb_info WHERE 1=1 `
  37. if condition != "" {
  38. sql += condition
  39. }
  40. sql += ` ORDER BY future_good_edb_info_id DESC `
  41. _, err = o.Raw(sql, pars).QueryRows(&list)
  42. return
  43. }
  44. // GetAllFutureGoodEdbInfoList 获取指标数据列表
  45. func GetAllFutureGoodEdbInfoList() (list []*FutureGoodEdbInfo, err error) {
  46. o := orm.NewOrmUsingDB("data")
  47. sql := `SELECT * FROM future_good_edb_info ORDER BY future_good_edb_info_id DESC `
  48. _, err = o.Raw(sql).QueryRows(&list)
  49. return
  50. }
  51. // GetFutureGoodEdbInfoListByParentId 根据父级ID获取指标数据列表
  52. func GetFutureGoodEdbInfoListByParentId(parentId int) (list []*FutureGoodEdbInfo, err error) {
  53. o := orm.NewOrmUsingDB("data")
  54. sql := `SELECT * FROM future_good_edb_info WHERE parent_id = ? ORDER BY future_good_edb_info_id ASC `
  55. _, err = o.Raw(sql, parentId).QueryRows(&list)
  56. return
  57. }
  58. // AddFutureGoodEdbInfo 添加期货数据库指标
  59. func AddFutureGoodEdbInfo(item *FutureGoodEdbInfo) (err error) {
  60. o := orm.NewOrmUsingDB("data")
  61. lastId, err := o.Insert(item)
  62. if err != nil {
  63. return
  64. }
  65. item.FutureGoodEdbInfoId = int(lastId)
  66. return
  67. }
  68. // Update 更新指标基础信息
  69. func (FutureGoodEdbInfo *FutureGoodEdbInfo) Update(cols []string) (err error) {
  70. o := orm.NewOrmUsingDB("data")
  71. _, err = o.Update(FutureGoodEdbInfo, cols...)
  72. return
  73. }
  74. // FutureGoodEdbInfoGroupListResp 期货指标数据列表数据返回
  75. type FutureGoodEdbInfoGroupListResp struct {
  76. FutureGoodEdbInfoId int
  77. FutureGoodEdbInfoName string
  78. Child []FutureGoodEdbInfoGroupListResp
  79. }
  80. // GetFutureGoodEdbInfoGroupList 获取分組指标数据列表
  81. func GetFutureGoodEdbInfoGroupList(condition string, pars []interface{}) (list []*FutureGoodEdbInfo, err error) {
  82. o := orm.NewOrmUsingDB("data")
  83. sql := `SELECT * FROM future_good_edb_info WHERE 1=1 `
  84. if condition != "" {
  85. sql += condition
  86. }
  87. sql += ` ORDER BY future_good_edb_info_id DESC `
  88. _, err = o.Raw(sql, pars).QueryRows(&list)
  89. return
  90. }
  91. // BarChartInfoReq 柱方图预览请求数据
  92. type BarChartInfoReq struct {
  93. EdbInfoIdList []BarChartInfoEdbItemReq `description:"指标信息"`
  94. DateList []BarChartInfoDateReq `description:"日期配置"`
  95. Sort BarChartInfoSortReq `description:"排序"`
  96. }
  97. // BarChartInfoEdbItemReq 柱方图预览请求数据(指标相关)
  98. type BarChartInfoEdbItemReq struct {
  99. EdbInfoId int `description:"指标ID"`
  100. Name string `description:"别名"`
  101. Source int `description:"1:ETA图库;2:商品价格"`
  102. }
  103. // BarChartInfoDateReq 柱方图预览请求数据(日期相关)
  104. type BarChartInfoDateReq struct {
  105. Type int `description:"配置类型"`
  106. Date string `description:"固定日期"`
  107. Value int `description:"N天的值"`
  108. Color string `description:"颜色"`
  109. Name string `description:"别名"`
  110. }
  111. // BarChartInfoSortReq 柱方图预览请求数据(排序相关)
  112. type BarChartInfoSortReq struct {
  113. Sort int `description:"排序类型,0:默认,1:升序,2:降序"`
  114. DateIndex int `description:"日期数据的下标,从0开始"`
  115. }