base_from_trade_zhengzhou.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BaseFromTradeZhengzhouIndex struct {
  7. BaseFromTradeZhengzhouIndexId int `orm:"column(base_from_trade_zhengzhou_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 AddBaseFromTradeZhengzhouIndex(item *BaseFromTradeZhengzhouIndex) (lastId int64, err error) {
  32. o := orm.NewOrm()
  33. lastId, err = o.Insert(item)
  34. return
  35. }
  36. func GetBaseFromTradeZhengzhouIndexAll(dateStr string) (list []*BaseFromTradeZhengzhouIndex, err error) {
  37. o := orm.NewOrm()
  38. sql := `SELECT * FROM base_from_trade_zhengzhou_index WHERE data_time>=?`
  39. _, err = o.Raw(sql, dateStr).QueryRows(&list)
  40. return
  41. }
  42. func ModifyBaseFromTradeZhengzhouIndex(dealValue, buyValue, soldValue int, dataId int) (err error) {
  43. o := orm.NewOrm()
  44. sql := `UPDATE base_from_trade_zhengzhou_index SET deal_value=?,buy_value=?,sold_value=?,modify_time=NOW() WHERE base_from_trade_zhengzhou_index_id=? `
  45. _, err = o.Raw(sql, dealValue, buyValue, soldValue, dataId).Exec()
  46. return
  47. }
  48. type ZhengzhouIndexResp struct {
  49. Ret int
  50. Msg string
  51. ErrMsg string
  52. ErrCode string
  53. Data []*BaseFromTradeZhengzhouIndex
  54. }
  55. func GetBaseFromTradeZhengzhouIndexMaxDate() (max_date time.Time, err error) {
  56. o := orm.NewOrm()
  57. sql := ` SELECT max(a.data_time)as max_date FROM base_from_trade_zhengzhou_index as a `
  58. err = o.Raw(sql).QueryRow(&max_date)
  59. return
  60. }