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

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

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

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

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