[monitor] 通知策略支持启用关闭
This commit is contained in:
@@ -4,6 +4,8 @@ import com.usthe.manager.pojo.entity.NoticeRule;
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NoticeRule数据库操作
|
* NoticeRule数据库操作
|
||||||
* @author tom
|
* @author tom
|
||||||
@@ -11,4 +13,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
*/
|
*/
|
||||||
public interface NoticeRuleDao extends JpaRepository<NoticeRule, Long>, JpaSpecificationExecutor<NoticeRule> {
|
public interface NoticeRuleDao extends JpaRepository<NoticeRule, Long>, JpaSpecificationExecutor<NoticeRule> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有已启用的通知策略
|
||||||
|
* @return 通知策略
|
||||||
|
*/
|
||||||
|
List<NoticeRule> findNoticeRulesByEnableTrue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -76,10 +75,10 @@ public class NoticeConfigServiceImpl implements NoticeConfigService {
|
|||||||
@Override
|
@Override
|
||||||
public List<NoticeReceiver> getReceiverFilterRule(Alert alert) {
|
public List<NoticeReceiver> getReceiverFilterRule(Alert alert) {
|
||||||
// todo 使用缓存
|
// todo 使用缓存
|
||||||
List<NoticeRule> rules = noticeRuleDao.findAll();
|
List<NoticeRule> rules = noticeRuleDao.findNoticeRulesByEnableTrue();
|
||||||
// todo 暂时规则是全部转发 后面实现更多匹配规则:告警状态选择 监控类型选择等
|
// todo 暂时规则是全部转发 后面实现更多匹配规则:告警状态选择 监控类型选择等
|
||||||
Set<Long> receiverIds = rules.stream()
|
Set<Long> receiverIds = rules.stream()
|
||||||
.filter(item -> item.isFilterAll() && item.isEnable())
|
.filter(NoticeRule::isFilterAll)
|
||||||
.map(NoticeRule::getReceiverId)
|
.map(NoticeRule::getReceiverId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
return noticeReceiverDao.findAllById(receiverIds);
|
return noticeReceiverDao.findAllById(receiverIds);
|
||||||
|
|||||||
@@ -234,6 +234,12 @@
|
|||||||
</nz-select>
|
</nz-select>
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
</nz-form-item >
|
</nz-form-item >
|
||||||
|
<nz-form-item>
|
||||||
|
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "enable">是否启用</nz-form-label>
|
||||||
|
<nz-form-control nzSpan="8">
|
||||||
|
<nz-switch [(ngModel)]="rule.enable" name="enable" id="enable"></nz-switch>
|
||||||
|
</nz-form-control>
|
||||||
|
</nz-form-item >
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</nz-modal>
|
</nz-modal>
|
||||||
|
|||||||
Reference in New Issue
Block a user