完善报警通知增删改功能.

pull/12/head
chen.ma 3 years ago
parent 3148987b2d
commit 69b755483f

@ -11,6 +11,11 @@ import lombok.Data;
@Data
public class NotifyReqDTO {
/**
* id
*/
private String id;
/**
* id
*/

@ -11,6 +11,11 @@ import lombok.Data;
@Data
public class NotifyRespDTO {
/**
* id
*/
private String id;
/**
* id
*/

@ -68,20 +68,18 @@ public class NotifyServiceImpl implements NotifyService {
@Override
public void save(NotifyReqDTO reqDTO) {
try {
notifyInfoMapper.insert(BeanUtil.convert(reqDTO, NotifyInfo.class));
} catch (DuplicateKeyException ex) {
if (existNotify(reqDTO)) {
throw new ServiceException("新增通知报警配置重复.");
}
notifyInfoMapper.insert(BeanUtil.convert(reqDTO, NotifyInfo.class));
}
@Override
public void update(NotifyReqDTO reqDTO) {
NotifyInfo notifyInfo = BeanUtil.convert(reqDTO, NotifyInfo.class);
LambdaUpdateWrapper<NotifyInfo> updateWrapper = Wrappers.lambdaUpdate(NotifyInfo.class)
.eq(NotifyInfo::getTenantId, reqDTO.getTenantId())
.eq(NotifyInfo::getItemId, reqDTO.getItemId())
.eq(NotifyInfo::getTpId, reqDTO.getTpId());
.eq(NotifyInfo::getId, reqDTO.getId());
try {
notifyInfoMapper.update(notifyInfo, updateWrapper);
@ -93,9 +91,7 @@ public class NotifyServiceImpl implements NotifyService {
@Override
public void delete(NotifyReqDTO reqDTO) {
LambdaUpdateWrapper<NotifyInfo> updateWrapper = Wrappers.lambdaUpdate(NotifyInfo.class)
.eq(NotifyInfo::getTenantId, reqDTO.getTenantId())
.eq(NotifyInfo::getItemId, reqDTO.getItemId())
.eq(NotifyInfo::getTpId, reqDTO.getTpId());
.eq(NotifyInfo::getId, reqDTO.getId());
notifyInfoMapper.delete(updateWrapper);
}
@ -111,4 +107,16 @@ public class NotifyServiceImpl implements NotifyService {
return notifyInfos;
}
private boolean existNotify(NotifyReqDTO reqDTO) {
LambdaQueryWrapper<NotifyInfo> queryWrapper = Wrappers.lambdaQuery(NotifyInfo.class)
.eq(NotifyInfo::getTenantId, reqDTO.getTenantId())
.eq(NotifyInfo::getItemId, reqDTO.getItemId())
.eq(NotifyInfo::getTpId, reqDTO.getTpId())
.eq(NotifyInfo::getPlatform, reqDTO.getPlatform())
.eq(NotifyInfo::getType, reqDTO.getType());
List<NotifyInfo> existNotifyInfos = notifyInfoMapper.selectList(queryWrapper);
return CollUtil.isNotEmpty(existNotifyInfos);
}
}

Loading…
Cancel
Save