diff --git a/src/main/java/com/xydl/cac/controller/BdzController.java b/src/main/java/com/xydl/cac/controller/BdzController.java index 85eab39..6d56ca4 100644 --- a/src/main/java/com/xydl/cac/controller/BdzController.java +++ b/src/main/java/com/xydl/cac/controller/BdzController.java @@ -49,7 +49,10 @@ public class BdzController extends BasicController { @PostMapping("delete") @ApiOperation("删除") - public Response delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception { + public Response delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } service.delete(id); return Response.success("OK"); } diff --git a/src/main/java/com/xydl/cac/controller/IcdConfigController.java b/src/main/java/com/xydl/cac/controller/IcdConfigController.java index e4251d4..b199963 100644 --- a/src/main/java/com/xydl/cac/controller/IcdConfigController.java +++ b/src/main/java/com/xydl/cac/controller/IcdConfigController.java @@ -2,6 +2,7 @@ package com.xydl.cac.controller; import com.xydl.cac.entity.IcdConfigType; import com.xydl.cac.entity.IcdConfigTypeAtt; +import com.xydl.cac.exception.BusinessException; import com.xydl.cac.model.ColumnModel; import com.xydl.cac.model.Response; import com.xydl.cac.service.DataService; @@ -72,14 +73,20 @@ public class IcdConfigController extends BasicController { @PostMapping("delete") @ApiOperation("删除ICD类型配置") - public Response delete(@Validated @NotNull(message = "ID不能为空!") Integer id) { + public Response delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } configService.delete(id); return Response.success("OK"); } @PostMapping("deleteAtt") @ApiOperation("删除ICD类型属性配置") - public Response deleteAtt(@Validated @NotNull(message = "attid不能为空!") Integer attid) { + public Response deleteAtt(@Validated @NotNull(message = "attid不能为空!") Integer attid) throws Exception { + if (attid == null) { + throw new BusinessException("attid不能为空!"); + } configService.deleteAtt(attid); return Response.success("OK"); } diff --git a/src/main/java/com/xydl/cac/controller/JgController.java b/src/main/java/com/xydl/cac/controller/JgController.java index 3b09309..6a1f127 100644 --- a/src/main/java/com/xydl/cac/controller/JgController.java +++ b/src/main/java/com/xydl/cac/controller/JgController.java @@ -41,7 +41,7 @@ public class JgController extends BasicController { @ApiOperation("更新") public Response update(@Validated @RequestBody Jg item) throws Exception { if (item.getId() == null) { - throw new BusinessException("ID不能为空!"); + throw new BusinessException("id不能为空!"); } service.update(item); return Response.success("OK"); @@ -50,6 +50,9 @@ public class JgController extends BasicController { @PostMapping("delete") @ApiOperation("删除") public Response delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } service.delete(id); return Response.success("OK"); } diff --git a/src/main/java/com/xydl/cac/controller/LxController.java b/src/main/java/com/xydl/cac/controller/LxController.java index b281184..6806e21 100644 --- a/src/main/java/com/xydl/cac/controller/LxController.java +++ b/src/main/java/com/xydl/cac/controller/LxController.java @@ -41,7 +41,7 @@ public class LxController extends BasicController { @ApiOperation("更新") public Response update(@Validated @RequestBody Lx item) throws Exception { if (item.getId() == null) { - throw new BusinessException("ID不能为空!"); + throw new BusinessException("id不能为空!"); } service.update(item); return Response.success("OK"); @@ -49,7 +49,10 @@ public class LxController extends BasicController { @PostMapping("delete") @ApiOperation("删除") - public Response delete(@Validated @NotNull(message = "ID不能为空!") Integer id) { + public Response delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } service.delete(id); return Response.success("OK"); } diff --git a/src/main/java/com/xydl/cac/controller/ModevTypeController.java b/src/main/java/com/xydl/cac/controller/ModevTypeController.java index 0eb86d2..be7e048 100644 --- a/src/main/java/com/xydl/cac/controller/ModevTypeController.java +++ b/src/main/java/com/xydl/cac/controller/ModevTypeController.java @@ -49,14 +49,20 @@ public class ModevTypeController extends BasicController { @PostMapping("delete") @ApiOperation("删除") - public Response delete(@Validated @NotNull(message = "ID不能为空!") Integer id) { + public Response delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } service.delete(id); return Response.success("OK"); } @PostMapping("detail") @ApiOperation("详情") - public Response detail(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception { + public Response detail(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } ModevType detail = service.detail(id); return Response.success(detail); } diff --git a/src/main/java/com/xydl/cac/controller/ModevTypePointController.java b/src/main/java/com/xydl/cac/controller/ModevTypePointController.java index 46d3f2f..f037cc9 100644 --- a/src/main/java/com/xydl/cac/controller/ModevTypePointController.java +++ b/src/main/java/com/xydl/cac/controller/ModevTypePointController.java @@ -1,6 +1,7 @@ package com.xydl.cac.controller; import com.xydl.cac.entity.ModevTypePoint; +import com.xydl.cac.exception.BusinessException; import com.xydl.cac.model.Response; import com.xydl.cac.service.ModevTypePointService; import io.swagger.annotations.Api; @@ -38,7 +39,10 @@ public class ModevTypePointController extends BasicController { @PostMapping("delete") @ApiOperation("删除") - public Response delete(@Validated @NotNull(message = "ID不能为空!") Integer id) { + public Response delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } service.delete(id); return Response.success("OK"); } diff --git a/src/main/java/com/xydl/cac/controller/NPointController.java b/src/main/java/com/xydl/cac/controller/NPointController.java index 958304f..fa9ed10 100644 --- a/src/main/java/com/xydl/cac/controller/NPointController.java +++ b/src/main/java/com/xydl/cac/controller/NPointController.java @@ -1,6 +1,7 @@ package com.xydl.cac.controller; import com.xydl.cac.entity.NPoint; +import com.xydl.cac.exception.BusinessException; import com.xydl.cac.model.Response; import com.xydl.cac.service.NPointService; import io.swagger.annotations.Api; @@ -40,7 +41,10 @@ public class NPointController extends BasicController { @PostMapping("delete") @ApiOperation("删除") - public Response delete(@Validated @NotNull(message = "ID不能为空!") @Param("id") Integer id) { + public Response delete(@Validated @NotNull(message = "id不能为空!") @Param("id") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } service.delete(id); return Response.success("OK"); } diff --git a/src/main/java/com/xydl/cac/controller/ParamBindController.java b/src/main/java/com/xydl/cac/controller/ParamBindController.java index f3bf421..986c96c 100644 --- a/src/main/java/com/xydl/cac/controller/ParamBindController.java +++ b/src/main/java/com/xydl/cac/controller/ParamBindController.java @@ -3,6 +3,7 @@ package com.xydl.cac.controller; import com.xydl.cac.entity.Bdz; import com.xydl.cac.entity.IcdConfigTypeInst; import com.xydl.cac.entity.Rptparamindex; +import com.xydl.cac.exception.BusinessException; import com.xydl.cac.model.BindDetail; import com.xydl.cac.model.BindingModel; import com.xydl.cac.model.Response; @@ -57,6 +58,9 @@ public class ParamBindController extends BasicController { @PostMapping("unbind") @ApiOperation("解绑") public Response unbind(@Validated @NotNull(message = "eqmid不能为空!") @Param("eqmid") Integer eqmid) throws Exception { + if (eqmid == null) { + throw new BusinessException("eqmid不能为空!"); + } bindService.unbind(eqmid); return Response.success("OK"); } @@ -64,6 +68,9 @@ public class ParamBindController extends BasicController { @GetMapping("getBind") @ApiOperation("查询绑定信息") public Response getBind(@Validated @NotNull(message = "eqmid不能为空!") @Param("eqmid") Integer eqmid) throws Exception { + if (eqmid == null) { + throw new BusinessException("eqmid不能为空!"); + } BindDetail result = bindService.getBind(eqmid); return Response.success(result); } diff --git a/src/main/java/com/xydl/cac/controller/UnitController.java b/src/main/java/com/xydl/cac/controller/UnitController.java index fcc5187..e1a1e5d 100644 --- a/src/main/java/com/xydl/cac/controller/UnitController.java +++ b/src/main/java/com/xydl/cac/controller/UnitController.java @@ -41,7 +41,7 @@ public class UnitController extends BasicController { @ApiOperation("更新") public Response update(@Validated @RequestBody Unit item) throws Exception { if (item.getId() == null) { - throw new BusinessException("ID不能为空!"); + throw new BusinessException("id不能为空!"); } service.update(item); return Response.success("OK"); @@ -49,7 +49,10 @@ public class UnitController extends BasicController { @PostMapping("delete") @ApiOperation("删除") - public Response delete(@Validated @NotNull(message = "ID不能为空!") Integer id) { + public Response delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } service.delete(id); return Response.success("OK"); } diff --git a/src/main/java/com/xydl/cac/controller/ZsbController.java b/src/main/java/com/xydl/cac/controller/ZsbController.java index 83ff7a7..1e94b3d 100644 --- a/src/main/java/com/xydl/cac/controller/ZsbController.java +++ b/src/main/java/com/xydl/cac/controller/ZsbController.java @@ -49,7 +49,10 @@ public class ZsbController extends BasicController { @PostMapping("delete") @ApiOperation("删除") - public Response delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception { + public Response delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception { + if (id == null) { + throw new BusinessException("id不能为空!"); + } service.delete(id); return Response.success("OK"); } diff --git a/src/main/java/com/xydl/cac/service/impl/NPointServiceImpl.java b/src/main/java/com/xydl/cac/service/impl/NPointServiceImpl.java index 080f9f4..7164d1e 100644 --- a/src/main/java/com/xydl/cac/service/impl/NPointServiceImpl.java +++ b/src/main/java/com/xydl/cac/service/impl/NPointServiceImpl.java @@ -2,6 +2,7 @@ package com.xydl.cac.service.impl; import com.xydl.cac.entity.NPoint; import com.xydl.cac.entity.NSensor; +import com.xydl.cac.exception.BusinessException; import com.xydl.cac.repository.NPointRepository; import com.xydl.cac.repository.NSensorRepository; import com.xydl.cac.service.NPointService; @@ -11,6 +12,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.List; @@ -39,6 +41,10 @@ public class NPointServiceImpl implements NPointService { @Override public NPoint add(NPoint item) throws Exception { + List list = repository.findBySensorIdAndField(item.getSensorId(), item.getField()); + if (!CollectionUtils.isEmpty(list)) { + throw new BusinessException("该监测装置的该字段已存在"); + } item.setId(null); return repository.save(item); }