base_from_trade_ine.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BaseFromTradeIneIndex struct {
  7. BaseFromTradeIneIndexId int `orm:"column(base_from_trade_ine_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 AddBaseFromTradeIneIndex(item *BaseFromTradeIneIndex) (lastId int64, err error) {
  32. o := orm.NewOrmUsingDB("data")
  33. lastId, err = o.Insert(item)
  34. return
  35. }
  36. func GetBaseFromTradeIneIndexAll(dateStr string) (list []*BaseFromTradeIneIndex, err error) {
  37. o := orm.NewOrmUsingDB("data")
  38. sql := `SELECT * FROM base_from_trade_ine_index where data_time=?`
  39. _, err = o.Raw(sql, dateStr).QueryRows(&list)
  40. return
  41. }
  42. func ModifyBaseFromTradeIneIndex(dealValue, buyValue, soldValue int, dataId int) (err error) {
  43. o := orm.NewOrmUsingDB("data")
  44. sql := `UPDATE base_from_trade_ine_index SET deal_value=?,buy_value=?,sold_value=?,modify_time=NOW() WHERE base_from_trade_ine_index_id=? `
  45. _, err = o.Raw(sql, dealValue, buyValue, soldValue, dataId).Exec()
  46. return
  47. }
  48. func GetIndexCodeFromMapping(exchange string) (list []*BaseFromTradeMapping, err error) {
  49. o := orm.NewOrmUsingDB("data")
  50. sql := `SELECT * FROM base_from_trade_mapping where exchange=?`
  51. _, err = o.Raw(sql, exchange).QueryRows(&list)
  52. return
  53. }
  54. func AddBaseFromTradeMapping(indexName, indexCode, exchange string) (err error) {
  55. o := orm.NewOrmUsingDB("data")
  56. sql := "Insert Into base_from_trade_mapping(index_name,index_code,exchange) Values('" + indexName + "','" + indexCode + "','" + exchange + "')"
  57. _, err = o.Raw(sql).Exec()
  58. return
  59. }