a275c30e155dc8c1684863995967e97d1cc02234.svn-base 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package cn.com.goldenwater.dcproj.controller.cdep;
  2. import cn.com.goldenwater.dcproj.model.BisInspCdepQua;
  3. import cn.com.goldenwater.dcproj.param.BisInspCdepQuaParam;
  4. import cn.com.goldenwater.dcproj.service.BisInspCdepQuaService;
  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/qua")
  27. public class BisInspCdepQuaController extends BaseController {
  28. private Logger logger = LoggerFactory.getLogger(getClass());
  29. @Autowired
  30. private BisInspCdepQuaService bisInspCdepQuaService;
  31. @ApiOperation(value = "添加或修改资质复核表(新疆)")
  32. @RequestMapping(value = "", method = RequestMethod.POST)
  33. public BaseResponse<BisInspCdepQua> insert(@ApiParam(name = "bisInspCdepQua", value = "BisInspCdepQua", required = true) @RequestBody BisInspCdepQua bisInspCdepQua) {
  34. if (StringUtils.isBlank(bisInspCdepQua.getRgstrId())){
  35. return buildFailResponse();
  36. }
  37. // 根据有无主键,来新增、更新信息
  38. int ret = 0;
  39. if(StringUtils.isBlank(bisInspCdepQua.getId())){
  40. BisInspCdepQuaParam param = new BisInspCdepQuaParam();
  41. param.setRgstrId(bisInspCdepQua.getRgstrId());
  42. BisInspCdepQua cap = bisInspCdepQuaService.getBy(param);
  43. if (null == cap){
  44. ret = bisInspCdepQuaService.insert(bisInspCdepQua);
  45. } else {
  46. bisInspCdepQua.setId(cap.getId());
  47. ret = bisInspCdepQuaService.update(bisInspCdepQua);
  48. }
  49. } else {
  50. ret = bisInspCdepQuaService.update(bisInspCdepQua);
  51. }
  52. return buildSuccessResponse(bisInspCdepQua);
  53. }
  54. @ApiOperation(value = "根据ID删除xxx")
  55. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  56. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  57. int ret = bisInspCdepQuaService.delete(id);
  58. return buildSuccessResponse();
  59. }
  60. @ApiOperation(value = "更新xxx信息")
  61. @RequestMapping(value = "/update", method = RequestMethod.POST)
  62. public BaseResponse<BisInspCdepQua> update(@ApiParam(name = "bisInspCdepQua", value = "BisInspCdepQua", required = true) @RequestBody BisInspCdepQua bisInspCdepQua) {
  63. Assert.notNull(bisInspCdepQua.getId(), "主键id为必填参数");
  64. int ret = bisInspCdepQuaService.update(bisInspCdepQua);
  65. return buildSuccessResponse(bisInspCdepQua);
  66. }
  67. @ApiOperation(value = "根据ID获取资质复核表(新疆)(单表)")
  68. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  69. public BaseResponse<BisInspCdepQua> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  70. //需要在mapper文件中,重写下面的get方法
  71. BisInspCdepQua bisInspCdepQua = bisInspCdepQuaService.get(id);
  72. if (null == bisInspCdepQua) {
  73. bisInspCdepQua = new BisInspCdepQua();
  74. bisInspCdepQua.setRgstrId(id);
  75. bisInspCdepQuaService.insert(bisInspCdepQua);
  76. }
  77. return buildSuccessResponse(bisInspCdepQua);
  78. }
  79. }