AlertDefineDao.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.usthe.alert.dao;
  2. import com.usthe.common.entity.alerter.AlertDefine;
  3. import org.springframework.data.jpa.repository.JpaRepository;
  4. import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  5. import org.springframework.data.jpa.repository.Query;
  6. import org.springframework.data.repository.query.Param;
  7. import java.util.List;
  8. import java.util.Set;
  9. /**
  10. * AlertDefine 数据库操作
  11. * @author tom
  12. * @date 2021/12/9 10:03
  13. */
  14. public interface AlertDefineDao extends JpaRepository<AlertDefine, Long>, JpaSpecificationExecutor<AlertDefine> {
  15. /**
  16. * 根据ID列表删除告警定义
  17. * @param alertDefineIds 告警定义ID列表
  18. */
  19. void deleteAlertDefinesByIdIn(Set<Long> alertDefineIds);
  20. /**
  21. * 根据监控ID查询与之关联的告警定义列表
  22. * @param monitorId 监控ID
  23. * @param metrics 指标组
  24. * @return 告警定义列表
  25. */
  26. @Query("select define from AlertDefine define join AlertDefineMonitorBind bind on bind.alertDefineId = define.id " +
  27. "where bind.monitorId = :monitorId and define.metric = :metrics and define.enable = true")
  28. List<AlertDefine> queryAlertDefinesByMonitor(@Param(value = "monitorId") Long monitorId,
  29. @Param(value = "metrics") String metrics);
  30. }