通知模块不允许相同配置同时存在.

pull/10/head
chen.ma 3 years ago
parent dfd62ba9ec
commit 6930e451c9

@ -1,6 +1,7 @@
package cn.hippo4j.config.service.biz.impl;
import cn.hippo4j.common.toolkit.GroupKey;
import cn.hippo4j.common.web.exception.ServiceException;
import cn.hippo4j.config.enums.DelEnum;
import cn.hippo4j.config.mapper.NotifyInfoMapper;
import cn.hippo4j.config.model.NotifyInfo;
@ -18,6 +19,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import java.util.List;
@ -66,7 +68,11 @@ public class NotifyServiceImpl implements NotifyService {
@Override
public void save(NotifyReqDTO reqDTO) {
notifyInfoMapper.insert(BeanUtil.convert(reqDTO, NotifyInfo.class));
try {
notifyInfoMapper.insert(BeanUtil.convert(reqDTO, NotifyInfo.class));
} catch (DuplicateKeyException ex) {
throw new ServiceException("新增通知报警配置重复.");
}
}
@Override
@ -77,7 +83,11 @@ public class NotifyServiceImpl implements NotifyService {
.eq(NotifyInfo::getItemId, reqDTO.getItemId())
.eq(NotifyInfo::getTpId, reqDTO.getTpId());
notifyInfoMapper.update(notifyInfo, updateWrapper);
try {
notifyInfoMapper.update(notifyInfo, updateWrapper);
} catch (DuplicateKeyException ex) {
throw new ServiceException("修改通知报警配置重复.");
}
}
@Override

@ -157,7 +157,7 @@ CREATE TABLE `notify` (
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
`del_flag` tinyint(1) NOT NULL COMMENT '是否删除',
PRIMARY KEY (`id`),
KEY `uk_notify_biz_key` (`tenant_id`,`item_id`,`tp_id`,`platform`,`type`,`del_flag`) USING BTREE
UNIQUE KEY `uk_notify_biz_key` (`tenant_id`,`item_id`,`tp_id`,`platform`,`type`,`del_flag`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通知表';
/* 租户 */

Loading…
Cancel
Save