预警规则新增编辑时校验规则修改
parent
0f38d35bfb
commit
450497f710
|
|
@ -47,18 +47,22 @@ public class OsmoticWarnRuleController {
|
||||||
Long id = dto.getId();
|
Long id = dto.getId();
|
||||||
LambdaQueryWrapper<OsmoticWarnRule> queryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<OsmoticWarnRule> queryWrapper = Wrappers.lambdaQuery();
|
||||||
queryWrapper.eq(OsmoticWarnRule::getStationCode,dto.getStationCode())
|
queryWrapper.eq(OsmoticWarnRule::getStationCode,dto.getStationCode())
|
||||||
.eq(OsmoticWarnRule::getType,dto.getType());
|
.eq(OsmoticWarnRule::getLevel,dto.getLevel());
|
||||||
|
if(dto.getType() == 3){
|
||||||
|
queryWrapper.eq(OsmoticWarnRule::getDirection,dto.getDirection());
|
||||||
|
}
|
||||||
if(id != null){
|
if(id != null){
|
||||||
queryWrapper.ne(OsmoticWarnRule::getId,id);
|
queryWrapper.ne(OsmoticWarnRule::getId,id);
|
||||||
}
|
}
|
||||||
if(service.count(queryWrapper ) > 0){
|
if(service.count(queryWrapper ) > 0){
|
||||||
throw new IllegalArgumentException("该站点已存在该类型的告警");
|
throw new IllegalArgumentException("该测点已存在该类型的告警");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改")
|
@Operation(summary = "修改")
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public R<OsmoticWarnRule> update(@Validated(Update.class) @RequestBody OsmoticWarnRule dto) {
|
public R<OsmoticWarnRule> update(@Validated(Update.class) @RequestBody OsmoticWarnRule dto) {
|
||||||
|
checkParam(dto);
|
||||||
boolean result = service.updateById(dto);
|
boolean result = service.updateById(dto);
|
||||||
return R.ok(result ? dto : null);
|
return R.ok(result ? dto : null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue