edb_data_zz.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type ZzData struct {
  8. InputValue string `orm:"column(DATA_VALUE)" description:"日期"`
  9. DataTime string `orm:"column(DATA_DATE)" description:"值"`
  10. }
  11. type BaseFromZzDataSimple struct {
  12. Id int `orm:"column(base_from_trade_zhengzhou_index_id);pk"`
  13. DealCode string
  14. BuyCode string
  15. SoldCode string
  16. DataTime string
  17. DealValue string
  18. BuyValue string
  19. SoldValue string
  20. }
  21. type BaseInfoFromZz struct {
  22. DealName string
  23. BuyName string
  24. SoldName string
  25. }
  26. type BaseFromTradeZhengzhouIndex struct {
  27. BaseFromTradeZhengzhouIndexId int `orm:"column(base_from_trade_zhengzhou_index_id);pk"`
  28. Rank int
  29. DealShortName string
  30. DealName string
  31. DealCode string
  32. DealValue string
  33. DealChange int
  34. BuyShortName string
  35. BuyName string
  36. BuyCode string
  37. BuyValue string
  38. BuyChange int
  39. SoldShortName string
  40. SoldName string
  41. SoldCode string
  42. SoldValue string
  43. SoldChange int
  44. Frequency string
  45. ClassifyName string
  46. ClassifyType string
  47. CreateTime time.Time
  48. ModifyTime time.Time
  49. DataTime string
  50. }
  51. func GetEdbDataZzMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
  52. o := orm.NewOrmUsingDB("data")
  53. sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_zz WHERE edb_code=? `
  54. err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
  55. return
  56. }
  57. // GetBaseInfoFromZhengzhouByIndexCode 获取指标信息
  58. func GetBaseInfoFromZhengzhouByIndexCode(indexCode, suffix string) (list []*BaseInfoFromZz, err error) {
  59. o := orm.NewOrmUsingDB("data")
  60. sql := `SELECT * FROM base_from_trade_zhengzhou_index WHERE %s_code=? `
  61. sql = fmt.Sprintf(sql, suffix)
  62. _, err = o.Raw(sql, indexCode).QueryRows(&list)
  63. return
  64. }