multiple_graph_config_edb_mapping.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // MultipleGraphConfigEdbMapping 指标与多图配置的关系表
  7. type MultipleGraphConfigEdbMapping struct {
  8. Id int `orm:"column(id);pk"`
  9. MultipleGraphConfigId int `description:"多图配置id"`
  10. EdbInfoId 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. // AddMultipleGraphConfigEdbMapping 新增多图配置
  16. func AddMultipleGraphConfigEdbMapping(item *MultipleGraphConfigEdbMapping) (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 *MultipleGraphConfigEdbMapping) Update(cols []string) (err error) {
  28. o := orm.NewOrmUsingDB("data")
  29. _, err = o.Update(item, cols...)
  30. return
  31. }
  32. // GetMultipleGraphConfigEdbMappingByIdAndSource 根据配置id和来源获取关联关系
  33. func GetMultipleGraphConfigEdbMappingByIdAndSource(configId, source int) (item *MultipleGraphConfigEdbMapping, err error) {
  34. o := orm.NewOrmUsingDB("data")
  35. sql := `SELECT * FROM multiple_graph_config_edb_mapping WHERE multiple_graph_config_id = ? AND source = ? `
  36. err = o.Raw(sql, configId, source).QueryRow(&item)
  37. return
  38. }
  39. // GetMultipleGraphConfigEdbMappingListById 根据配置id获取所有关联关系
  40. func GetMultipleGraphConfigEdbMappingListById(configId int) (items []*MultipleGraphConfigEdbMapping, err error) {
  41. o := orm.NewOrmUsingDB("data")
  42. sql := `SELECT * FROM multiple_graph_config_edb_mapping WHERE multiple_graph_config_id = ? `
  43. _, err = o.Raw(sql, configId).QueryRows(&items)
  44. return
  45. }