[manager]feature: zh and en annotations for code, delete notification when edit query is empty (#86)
* feat: MonitorsController Chinese and English support #huacheng * feat: [manager]feature:Delete notification operation compatibility query is empty #huacheng
This commit is contained in:
@@ -60,8 +60,10 @@ public class NoticeConfigController {
|
||||
@ApiOperation(value = "Delete existing recipient information", notes = "删除已存在的接收人信息")
|
||||
public ResponseEntity<Message<Void>> deleteNoticeReceiver(
|
||||
@ApiParam(value = "en: Recipient ID,zh: 接收人ID", example = "6565463543") @PathVariable("id") final Long receiverId) {
|
||||
// Returns success if it does not exist or if the deletion is successful
|
||||
// todo 不存在或删除成功都返回成功
|
||||
NoticeReceiver noticeReceiver = noticeConfigService.getReceiverById(receiverId);
|
||||
if (noticeReceiver == null) {
|
||||
return ResponseEntity.ok(new Message<>("The relevant information of the recipient could not be found, please check whether the parameters are correct"));
|
||||
}
|
||||
noticeConfigService.deleteReceiver(receiverId);
|
||||
return ResponseEntity.ok(new Message<>("Delete success"));
|
||||
}
|
||||
@@ -72,7 +74,6 @@ public class NoticeConfigController {
|
||||
public ResponseEntity<Message<List<NoticeReceiver>>> getReceivers(
|
||||
@ApiParam(value = "en: Recipient name,zh: 接收人名称,模糊查询", example = "tom") @RequestParam(required = false) final String name) {
|
||||
|
||||
//todo Writing can be optimized 写法可优化
|
||||
Specification<NoticeReceiver> specification = (root, query, criteriaBuilder) -> {
|
||||
Predicate predicate = criteriaBuilder.conjunction();
|
||||
if (name != null && !"".equals(name)) {
|
||||
@@ -107,6 +108,10 @@ public class NoticeConfigController {
|
||||
@ApiParam(value = "en: Notification Policy ID,zh: 通知策略ID", example = "6565463543") @PathVariable("id") final Long ruleId) {
|
||||
// Returns success if it does not exist or if the deletion is successful
|
||||
// todo 不存在或删除成功都返回成功
|
||||
NoticeRule noticeRule = noticeConfigService.getNoticeRulesById(ruleId);
|
||||
if (noticeRule == null) {
|
||||
return ResponseEntity.ok(new Message<>("The specified notification rule could not be queried, please check whether the parameters are correct"));
|
||||
}
|
||||
noticeConfigService.deleteNoticeRule(ruleId);
|
||||
return ResponseEntity.ok(new Message<>("Delete success"));
|
||||
}
|
||||
|
||||
@@ -90,4 +90,22 @@ public interface NoticeConfigService {
|
||||
* @return Receiver 接收人
|
||||
*/
|
||||
List<NoticeReceiver> getReceiverFilterRule(Alert alert);
|
||||
|
||||
/**
|
||||
* Query recipient information based on recipient ID (primary key Id)
|
||||
* 根据接收人ID(主键Id)查询接收人信息
|
||||
*
|
||||
* @param receiverId Receiver ID (primary key ID) 接收人ID(主键ID)
|
||||
* @return Recipient Entity 接收人实体
|
||||
*/
|
||||
NoticeReceiver getReceiverById(Long receiverId);
|
||||
|
||||
/**
|
||||
* Query specific notification rules according to the rule ID (primary key ID)
|
||||
* 根据规则ID(主键ID)查询具体通知规则
|
||||
*
|
||||
* @param ruleId Rule ID 规则ID(主键ID)
|
||||
* @return Notification Rule Entity 通知规则实体
|
||||
*/
|
||||
NoticeRule getNoticeRulesById(Long ruleId);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 消息通知配置实现
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/16 16:16
|
||||
*/
|
||||
@@ -74,13 +75,24 @@ public class NoticeConfigServiceImpl implements NoticeConfigService {
|
||||
|
||||
@Override
|
||||
public List<NoticeReceiver> getReceiverFilterRule(Alert alert) {
|
||||
// todo 使用缓存
|
||||
// todo use cache 使用缓存
|
||||
List<NoticeRule> rules = noticeRuleDao.findNoticeRulesByEnableTrue();
|
||||
// todo 暂时规则是全部转发 后面实现更多匹配规则:告警状态选择 监控类型选择等
|
||||
// todo The temporary rule is to forward all, and then implement more matching rules: alarm status selection, monitoring type selection, etc.
|
||||
// 暂时规则是全部转发 后面实现更多匹配规则:告警状态选择 监控类型选择等
|
||||
Set<Long> receiverIds = rules.stream()
|
||||
.filter(NoticeRule::isFilterAll)
|
||||
.map(NoticeRule::getReceiverId)
|
||||
.collect(Collectors.toSet());
|
||||
return noticeReceiverDao.findAllById(receiverIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoticeReceiver getReceiverById(Long receiverId) {
|
||||
return noticeReceiverDao.getOne(receiverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoticeRule getNoticeRulesById(Long ruleId) {
|
||||
return noticeRuleDao.getOne(ruleId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user