277dd5203d0fc4423315ef490edceee643ffcf50.svn-base 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package cn.com.goldenwater.dcproj.controller.cdep;
  2. import cn.com.goldenwater.dcproj.model.BisInspCdepBeh;
  3. import cn.com.goldenwater.dcproj.param.BisInspCdepBehParam;
  4. import cn.com.goldenwater.dcproj.service.BisInspCdepBehService;
  5. import cn.com.goldenwater.core.web.BaseController;
  6. import cn.com.goldenwater.core.web.BaseResponse;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiOperation;
  9. import io.swagger.annotations.ApiParam;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.slf4j.Logger;
  12. import org.slf4j.LoggerFactory;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.util.Assert;
  15. import org.springframework.web.bind.annotation.PathVariable;
  16. import org.springframework.web.bind.annotation.RequestBody;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RequestMethod;
  19. import org.springframework.web.bind.annotation.RestController;
  20. /**
  21. * @author zhangcheng
  22. * @date 2020-11-19
  23. */
  24. @Api(value = "行为检测能力管理",tags="行为检测能力管理")
  25. @RestController
  26. @RequestMapping("/bis/insp/cdep/beh")
  27. public class BisInspCdepBehController extends BaseController {
  28. private Logger logger = LoggerFactory.getLogger(getClass());
  29. @Autowired
  30. private BisInspCdepBehService bisInspCdepBehService;
  31. @ApiOperation(value = "添加或修改行为检测能力表(新疆)")
  32. @RequestMapping(value = "", method = RequestMethod.POST)
  33. public BaseResponse<BisInspCdepBeh> insert(@ApiParam(name = "bisInspCdepBeh", value = "BisInspCdepBeh", required = true) @RequestBody BisInspCdepBeh bisInspCdepBeh) {
  34. if (StringUtils.isBlank(bisInspCdepBeh.getRgstrId())){
  35. return buildFailResponse();
  36. }
  37. // 根据有无主键,来新增、更新信息
  38. int ret = 0;
  39. if(StringUtils.isBlank(bisInspCdepBeh.getId())){
  40. BisInspCdepBehParam param = new BisInspCdepBehParam();
  41. param.setRgstrId(bisInspCdepBeh.getRgstrId());
  42. BisInspCdepBeh beh = bisInspCdepBehService.getBy(param);
  43. if (null == beh){
  44. ret = bisInspCdepBehService.insert(bisInspCdepBeh);
  45. } else {
  46. bisInspCdepBeh.setId(beh.getId());
  47. ret = bisInspCdepBehService.update(bisInspCdepBeh);
  48. }
  49. } else {
  50. bisInspCdepBeh.setPersId(getCurrentPersId());
  51. ret = bisInspCdepBehService.update(bisInspCdepBeh);
  52. }
  53. return buildSuccessResponse(bisInspCdepBeh);
  54. }
  55. @ApiOperation(value = "根据ID删除xxx")
  56. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  57. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  58. int ret = bisInspCdepBehService.delete(id);
  59. return buildSuccessResponse();
  60. }
  61. @ApiOperation(value = "更新xxx信息")
  62. @RequestMapping(value = "/update", method = RequestMethod.POST)
  63. public BaseResponse<BisInspCdepBeh> update(@ApiParam(name = "bisInspCdepBeh", value = "BisInspCdepBeh", required = true) @RequestBody BisInspCdepBeh bisInspCdepBeh) {
  64. Assert.notNull(bisInspCdepBeh.getId(), "主键id为必填参数");
  65. int ret = bisInspCdepBehService.update(bisInspCdepBeh);
  66. return buildSuccessResponse(bisInspCdepBeh);
  67. }
  68. @ApiOperation(value = "根据ID获取行为检测能力表(新疆)(单表)")
  69. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  70. public BaseResponse<BisInspCdepBeh> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  71. BisInspCdepBeh bisInspCdepBeh = bisInspCdepBehService.get(id);
  72. if (null == bisInspCdepBeh){
  73. bisInspCdepBeh = new BisInspCdepBeh();
  74. bisInspCdepBeh.setRgstrId(id);
  75. bisInspCdepBehService.insert(bisInspCdepBeh);
  76. }
  77. return buildSuccessResponse(bisInspCdepBeh);
  78. }
  79. }