my_chart.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package data
  2. import (
  3. "eta/eta_api/models/data_manage"
  4. "eta/eta_api/utils"
  5. "fmt"
  6. )
  7. // GetMyChartClassifyIdNumMap 我的图表-获取分类ID及图表数map
  8. func GetMyChartClassifyIdNumMap(adminId int) (chartsNumMap map[int]int, err error) {
  9. chartsNumMap = make(map[int]int)
  10. // 获取当前账号的不可见指标
  11. chartIds := make([]int, 0)
  12. obj := data_manage.EdbInfoNoPermissionAdmin{}
  13. charts, e := obj.GetAllChartListByAdminId(adminId)
  14. if e != nil && e.Error() != utils.ErrNoRow() {
  15. err = fmt.Errorf("获取不可见指标配置数据失败, err: %s", e.Error())
  16. return
  17. }
  18. for _, v := range charts {
  19. chartIds = append(chartIds, v.ChartInfoId)
  20. }
  21. cond := ``
  22. pars := make([]interface{}, 0)
  23. lenChart := len(chartIds)
  24. if lenChart > 0 {
  25. cond += ` AND d.chart_info_id NOT IN (` + utils.GetOrmInReplace(lenChart) + `) `
  26. pars = append(pars, chartIds)
  27. }
  28. // 分类图表数
  29. chartsNum, e := data_manage.GetMyChartClassifyIdAndNum(cond, pars)
  30. if e != nil {
  31. err = fmt.Errorf("获取分类图表数失败, err: %s", e.Error())
  32. return
  33. }
  34. for _, v := range chartsNum {
  35. chartsNumMap[v.MyChartClassifyId] = v.ChartNum
  36. }
  37. return
  38. }