perf: 优化id校验

dev
huangfeng 1 year ago
parent 27345fcecf
commit aea209027e

@ -49,7 +49,10 @@ public class BdzController extends BasicController {
@PostMapping("delete")
@ApiOperation("删除")
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
public Response<String> delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
if (id == null) {
throw new BusinessException("id不能为空!");
}
service.delete(id);
return Response.success("OK");
}

@ -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<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
public Response<String> 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<String> deleteAtt(@Validated @NotNull(message = "attid不能为空!") Integer attid) {
public Response<String> deleteAtt(@Validated @NotNull(message = "attid不能为空!") Integer attid) throws Exception {
if (attid == null) {
throw new BusinessException("attid不能为空!");
}
configService.deleteAtt(attid);
return Response.success("OK");
}

@ -41,7 +41,7 @@ public class JgController extends BasicController {
@ApiOperation("更新")
public Response<String> 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<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
if (id == null) {
throw new BusinessException("id不能为空!");
}
service.delete(id);
return Response.success("OK");
}

@ -41,7 +41,7 @@ public class LxController extends BasicController {
@ApiOperation("更新")
public Response<String> 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<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
public Response<String> delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
if (id == null) {
throw new BusinessException("id不能为空!");
}
service.delete(id);
return Response.success("OK");
}

@ -49,14 +49,20 @@ public class ModevTypeController extends BasicController {
@PostMapping("delete")
@ApiOperation("删除")
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
public Response<String> 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<ModevType> detail(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
public Response<ModevType> 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);
}

@ -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<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
public Response<String> delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
if (id == null) {
throw new BusinessException("id不能为空!");
}
service.delete(id);
return Response.success("OK");
}

@ -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<String> delete(@Validated @NotNull(message = "ID不能为空!") @Param("id") Integer id) {
public Response<String> 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");
}

@ -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<String> 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<BindDetail> 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);
}

@ -41,7 +41,7 @@ public class UnitController extends BasicController {
@ApiOperation("更新")
public Response<String> 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<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
public Response<String> delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
if (id == null) {
throw new BusinessException("id不能为空!");
}
service.delete(id);
return Response.success("OK");
}

@ -49,7 +49,10 @@ public class ZsbController extends BasicController {
@PostMapping("delete")
@ApiOperation("删除")
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
public Response<String> delete(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
if (id == null) {
throw new BusinessException("id不能为空!");
}
service.delete(id);
return Response.success("OK");
}

@ -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<NPoint> list = repository.findBySensorIdAndField(item.getSensorId(), item.getField());
if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException("该监测装置的该字段已存在");
}
item.setId(null);
return repository.save(item);
}

Loading…
Cancel
Save