chart_info_elastic.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package services
  2. import (
  3. "eta/eta_forum_hub/models"
  4. "eta/eta_forum_hub/services/elastic"
  5. "eta/eta_forum_hub/utils"
  6. "fmt"
  7. "strconv"
  8. )
  9. // EsAddOrEditChartInfo 新增和修改ES中的图表数据
  10. func EsAddOrEditChartInfo(chartInfoId int) {
  11. var err error
  12. defer func() {
  13. if err != nil {
  14. fmt.Println("新增和修改ES中的图表数据失败:", err.Error())
  15. }
  16. }()
  17. itemInfo, _ := models.GetChartInfoById(chartInfoId)
  18. //添加es
  19. err = elastic.EsAddOrEditChartInfoData(utils.CHART_INDEX_NAME, strconv.Itoa(itemInfo.ChartInfoId), itemInfo)
  20. return
  21. }
  22. // DeleteEdbInfoToEs 删除ES中的指标
  23. func DeleteEdbInfoToEs(edbInfoId int) {
  24. //添加es
  25. go elastic.EsDeleteEdbInfoData(utils.DATA_INDEX_NAME, strconv.Itoa(edbInfoId))
  26. }
  27. // EsDeleteChartInfo 删除ES中的图表数据
  28. func EsDeleteChartInfo(chartInfoId int) {
  29. var err error
  30. defer func() {
  31. if err != nil {
  32. fmt.Println("删除ES中的图表数据失败:", err.Error())
  33. }
  34. }()
  35. //添加es
  36. err = elastic.EsDeleteDataV2(utils.CHART_INDEX_NAME, strconv.Itoa(chartInfoId))
  37. return
  38. }
  39. // EsSearchChartInfo 搜索图表信息
  40. func EsSearchChartInfo(keyword string, showSysId []int, sourceList []int, permissionClassifyIdList []int, startSize, pageSize int) (list []*models.ChartInfo, total int64, err error) {
  41. list, total, err = elastic.SearchChartInfoData(utils.CHART_INDEX_NAME, keyword, showSysId, sourceList, permissionClassifyIdList, startSize, pageSize)
  42. return
  43. }