chart_edb_mapping.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package data_manage
  2. import (
  3. "github.com/rdlucklib/rdluck_tools/orm"
  4. "time"
  5. )
  6. type ChartEdbMapping struct {
  7. ChartEdbMappingId int `orm:"column(chart_edb_mapping_id);pk"`
  8. ChartInfoId int `description:"图表id"`
  9. EdbInfoId int `description:"指标id"`
  10. CreateTime time.Time `description:"创建时间"`
  11. ModifyTime time.Time `description:"修改时间"`
  12. UniqueCode string `description:"唯一编码"`
  13. MaxData float64 `description:"上限"`
  14. MinData float64 `description:"下限"`
  15. IsOrder bool `description:"true:正序,false:逆序"`
  16. IsAxis int `description:"true:左轴,false:右轴"`
  17. EdbInfoType int `description:"true:标准指标,false:领先指标"`
  18. LeadValue int `description:"领先值"`
  19. LeadUnit string `description:"领先单位"`
  20. ChartStyle string `description:"图表类型"`
  21. ChartColor string `description:"颜色"`
  22. ChartWidth float64 `description:"线条大小"`
  23. }
  24. func AddChartEdbMapping(items []*ChartEdbMapping) (err error) {
  25. o := orm.NewOrm()
  26. o.Using("data")
  27. _, err = o.InsertMulti(1, items)
  28. return
  29. }
  30. func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
  31. o := orm.NewOrm()
  32. o.Using("data")
  33. sql := ` SELECT a.*,b.source_name,b.source,b.edb_code,b.edb_name,b.frequency,b.unit,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code
  34. FROM chart_edb_mapping AS a
  35. INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  36. WHERE chart_info_id=?
  37. ORDER BY chart_edb_mapping_id ASC `
  38. _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
  39. return
  40. }
  41. func GetChartEdbMappingListByEdbInfoId(edbInfoStr string) (list []*ChartEdbInfoMapping, err error) {
  42. o := orm.NewOrm()
  43. o.Using("data")
  44. sql := ` SELECT *
  45. FROM edb_info
  46. WHERE edb_info_id IN(` + edbInfoStr + `)
  47. ORDER BY FIELD(edb_info_id,` + edbInfoStr + `)
  48. `
  49. _, err = o.Raw(sql).QueryRows(&list)
  50. return
  51. }