multiple_graph_config_chart_mapping.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // MultipleGraphConfigChartMapping 图表与多图配置的关系表
  7. type MultipleGraphConfigChartMapping struct {
  8. Id int `orm:"column(id);pk"`
  9. MultipleGraphConfigId int `description:"多图配置id"`
  10. ChartInfoId int `description:"图表id"`
  11. Source int `description:"来源,1:曲线图,2:相关性图;3:滚动相关性图1;4:滚动相关性图2;"`
  12. ModifyTime time.Time `description:"最近一次修改时间"`
  13. CreateTime time.Time `description:"添加时间"`
  14. }
  15. // AddMultipleGraphConfigChartMapping 新增多图配置
  16. func AddMultipleGraphConfigChartMapping(item *MultipleGraphConfigChartMapping) (err error) {
  17. o := orm.NewOrmUsingDB("data")
  18. // 表格信息入库
  19. lastId, err := o.Insert(item)
  20. if err != nil {
  21. return
  22. }
  23. item.Id = int(lastId)
  24. return
  25. }
  26. // Update 更新 基础信息
  27. func (item *MultipleGraphConfigChartMapping) Update(cols []string) (err error) {
  28. o := orm.NewOrmUsingDB("data")
  29. _, err = o.Update(item, cols...)
  30. return
  31. }
  32. // GetMultipleGraphConfigChartMappingByIdAndSource 根据配置id和来源获取关联关系
  33. func GetMultipleGraphConfigChartMappingByIdAndSource(configId, source int) (item *MultipleGraphConfigChartMapping, err error) {
  34. o := orm.NewOrmUsingDB("data")
  35. sql := `SELECT * FROM multiple_graph_config_chart_mapping WHERE multiple_graph_config_id = ? AND source = ? `
  36. err = o.Raw(sql, configId, source).QueryRow(&item)
  37. return
  38. }
  39. // GetMultipleGraphConfigChartMappingByChartId 根据图表id和来源获取关联关系
  40. func GetMultipleGraphConfigChartMappingByChartId(chartId int) (item *MultipleGraphConfigChartMapping, err error) {
  41. o := orm.NewOrmUsingDB("data")
  42. sql := `SELECT * FROM multiple_graph_config_chart_mapping WHERE chart_info_id = ? `
  43. err = o.Raw(sql, chartId).QueryRow(&item)
  44. return
  45. }
  46. // GetMultipleGraphConfigChartMappingListById 根据配置id获取所有关联关系
  47. func GetMultipleGraphConfigChartMappingListById(configId int) (items []*MultipleGraphConfigChartMapping, err error) {
  48. o := orm.NewOrmUsingDB("data")
  49. sql := `SELECT * FROM multiple_graph_config_chart_mapping WHERE multiple_graph_config_id = ? `
  50. _, err = o.Raw(sql, configId).QueryRows(&items)
  51. return
  52. }