base_from_trade_zhengzhou.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package data_manage
  2. import (
  3. "eta_gn/eta_task/global"
  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. err = global.DEFAULT_DmSQL.Create(item).Error
  35. if err != nil {
  36. return
  37. }
  38. lastId = int64(item.BaseFromTradeZhengzhouIndexId)
  39. return
  40. }
  41. func GetBaseFromTradeZhengzhouIndexAll(dateStr string) (list []*BaseFromTradeZhengzhouIndex, err error) {
  42. //o := orm.NewOrm()
  43. sql := `SELECT * FROM base_from_trade_zhengzhou_index WHERE data_time>=?`
  44. //_, err = o.Raw(sql, dateStr).QueryRows(&list)
  45. err = global.DEFAULT_DmSQL.Raw(sql, dateStr).Find(&list).Error
  46. return
  47. }
  48. func ModifyBaseFromTradeZhengzhouIndex(dealValue, buyValue, soldValue int, dataId int) (err error) {
  49. //o := orm.NewOrm()
  50. sql := `UPDATE base_from_trade_zhengzhou_index SET deal_value=?,buy_value=?,sold_value=?,modify_time=NOW() WHERE base_from_trade_zhengzhou_index_id=? `
  51. //_, err = o.Raw(sql, dealValue, buyValue, soldValue, dataId).Exec()
  52. err = global.DEFAULT_DmSQL.Exec(sql, dealValue, buyValue, soldValue, dataId).Error
  53. return
  54. }
  55. type ZhengzhouIndexResp struct {
  56. Ret int
  57. Msg string
  58. ErrMsg string
  59. ErrCode string
  60. Data []*BaseFromTradeZhengzhouIndex
  61. }
  62. func GetBaseFromTradeZhengzhouIndexMaxDate() (max_date time.Time, err error) {
  63. //o := orm.NewOrm()
  64. sql := ` SELECT max(a.data_time)as max_date FROM base_from_trade_zhengzhou_index as a `
  65. //err = o.Raw(sql).QueryRow(&max_date)
  66. err = global.DEFAULT_DmSQL.Raw(sql).Scan(&max_date).Error
  67. return
  68. }