base_from_trade_cffex.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BaseFromTradeCffexIndex struct {
  7. BaseFromTradeCffexIndexId int `orm:"column(base_from_trade_cffex_index_id);pk"`
  8. Rank int
  9. DealShortName string
  10. DealName string
  11. DealCode string
  12. DealValue int
  13. DealChange int
  14. BuyShortName string
  15. BuyName string
  16. BuyCode string
  17. BuyValue int
  18. BuyChange int
  19. SoldShortName string
  20. SoldName string
  21. SoldCode string
  22. SoldValue int
  23. SoldChange int
  24. Frequency string
  25. ClassifyName string
  26. ClassifyType string
  27. CreateTime time.Time
  28. ModifyTime time.Time
  29. DataTime string
  30. }
  31. func AddBaseFromTradeCffexIndex(item *BaseFromTradeCffexIndex) (lastId int64, err error) {
  32. o := orm.NewOrm()
  33. lastId, err = o.Insert(item)
  34. return
  35. }
  36. func GetBaseFromTradeCffexIndexAll(dateStr string) (list []*BaseFromTradeCffexIndex, err error) {
  37. o := orm.NewOrm()
  38. sql := `SELECT * FROM base_from_trade_cffex_index WHERE data_time=?`
  39. _, err = o.Raw(sql, dateStr).QueryRows(&list)
  40. return
  41. }
  42. func ModifyBaseFromTradeCffexIndex(columnList [5]string, dataList [5]interface{}, dataId int) (err error) {
  43. o := orm.NewOrm()
  44. sql := "UPDATE base_from_trade_cffex_index SET " +
  45. columnList[0] + "=?," + columnList[1] + "=?," + columnList[2] + "=?," + columnList[3] + "=?," + columnList[4] +
  46. "=?,modify_time=NOW() WHERE base_from_trade_cffex_index_id=? "
  47. _, err = o.Raw(sql, dataList[0], dataList[1], dataList[2], dataList[3], dataList[4], dataId).Exec()
  48. return
  49. }
  50. type CffexIndexResp struct {
  51. Ret int
  52. Msg string
  53. ErrMsg string
  54. ErrCode string
  55. Data []*BaseFromTradeCffexIndex
  56. }
  57. func GetBaseFromTradeCffexIndexMaxDate() (max_date time.Time, err error) {
  58. o := orm.NewOrm()
  59. sql := ` SELECT max(a.data_time)as max_date FROM base_from_trade_cffex_index as a `
  60. err = o.Raw(sql).QueryRow(&max_date)
  61. return
  62. }