c85d907e2f472c9e4431b0c85fd04e3bf129b63c.svn-base 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package cn.com.goldenwater.dcproj.controller.wr;
  2. import cn.com.goldenwater.dcproj.model.WrGwsB;
  3. import cn.com.goldenwater.dcproj.param.WrGwsBParam;
  4. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  5. import cn.com.goldenwater.dcproj.service.WrGwsBService;
  6. import cn.com.goldenwater.core.web.BaseController;
  7. import cn.com.goldenwater.core.web.BaseResponse;
  8. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import io.swagger.annotations.ApiParam;
  12. import com.github.pagehelper.PageInfo;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.PathVariable;
  18. import org.springframework.web.bind.annotation.RequestBody;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestMethod;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import java.util.ArrayList;
  23. import java.util.List;
  24. import com.alibaba.fastjson.JSONObject;
  25. /**
  26. * @author zhengdafei
  27. * @date 2019-3-3
  28. */
  29. @Api(value = "", tags = "地下水水源地基本信息表")
  30. @RestController
  31. @RequestMapping("/dc/insp/wrGwsB")
  32. public class WrGwsBController extends BaseController {
  33. private Logger logger = LoggerFactory.getLogger(getClass());
  34. @Autowired
  35. private WrGwsBService wrGwsBService;
  36. @Autowired
  37. private OlBisInspOrgService olBisInspOrgService;
  38. @ApiOperation(value = "添加")
  39. @RequestMapping(value = "/insert", method = RequestMethod.POST)
  40. public BaseResponse<JSONObject> insert(@ApiParam(name = "wrGwsB", value = "WrGwsB", required = true) @RequestBody WrGwsB wrGwsB) {
  41. String uuid = "";
  42. JSONObject json = new JSONObject();
  43. try {
  44. if (StringUtils.isNotBlank(wrGwsB.getGwsCd())) {
  45. String cwsCd = wrGwsB.getGwsCd().substring(0, 6) + "000000";
  46. wrGwsB.setAdCode(cwsCd);
  47. }
  48. uuid = wrGwsBService.add(wrGwsB);
  49. json.put("id", uuid);
  50. } catch (Exception e) {
  51. e.printStackTrace();
  52. logger.error(e.getMessage());
  53. return buildFailResponse(e.getMessage());
  54. }
  55. return buildSuccessResponse(json);
  56. }
  57. @ApiOperation(value = "根据ID删除")
  58. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  59. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  60. int ret = wrGwsBService.delete(id);
  61. JSONObject json = new JSONObject();
  62. json.put("code", ret);
  63. return buildSuccessResponse(json);
  64. }
  65. @ApiOperation(value = "更新信息")
  66. @RequestMapping(value = "/update", method = RequestMethod.POST)
  67. public BaseResponse update(@ApiParam(name = "wrGwsB", value = "WrGwsB", required = true) @RequestBody WrGwsB wrGwsB) {
  68. try {
  69. wrGwsBService.modify(wrGwsB);
  70. } catch (Exception e) {
  71. e.printStackTrace();
  72. logger.error(e.getMessage());
  73. return buildFailResponse(e.getMessage());
  74. }
  75. return buildSuccessResponse(wrGwsB);
  76. }
  77. @ApiOperation(value = "根据ID获取(单表)")
  78. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  79. public BaseResponse<WrGwsB> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  80. WrGwsB wrGwsB = wrGwsBService.get(id);
  81. return buildSuccessResponse(wrGwsB);
  82. }
  83. @ApiOperation(value = "获取列表(分页)")
  84. @RequestMapping(value = "/queryListByPage", method = {RequestMethod.POST})
  85. public BaseResponse<PageInfo<WrGwsB>> queryListByPage(@RequestBody WrGwsBParam param) {
  86. PageInfo<WrGwsB> list = new PageInfo<>();
  87. param.setProvince(AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId())));
  88. try {
  89. String adCode = param.getAdCode();
  90. if (adCode.contains("00")) {
  91. adCode = adCode.replace("00", "");
  92. param.setAdCode(adCode);
  93. }
  94. list = wrGwsBService.queryListByPage(param);
  95. } catch (Exception e) {
  96. e.printStackTrace();
  97. logger.error(e.getMessage());
  98. return buildFailResponse(e.getMessage());
  99. }
  100. return buildSuccessResponse(list);
  101. }
  102. @ApiOperation(value = "获取列表")
  103. @RequestMapping(value = "/queryList", method = {RequestMethod.POST})
  104. public BaseResponse<List<WrGwsB>> queryList(@RequestBody WrGwsBParam param) {
  105. List<WrGwsB> list = new ArrayList<>();
  106. try {
  107. list = wrGwsBService.queryList(param);
  108. } catch (Exception e) {
  109. e.printStackTrace();
  110. logger.error(e.getMessage());
  111. return buildFailResponse(e.getMessage());
  112. }
  113. return buildSuccessResponse(list);
  114. }
  115. @ApiOperation(value = "获取一个对象")
  116. @RequestMapping(value = "/getBy", method = {RequestMethod.POST})
  117. public BaseResponse<WrGwsB> getBy(@RequestBody WrGwsBParam param) {
  118. WrGwsB one = new WrGwsB();
  119. try {
  120. one = wrGwsBService.getBy(param);
  121. } catch (Exception e) {
  122. e.printStackTrace();
  123. logger.error(e.getMessage());
  124. return buildFailResponse(e.getMessage());
  125. }
  126. return buildSuccessResponse(one);
  127. }
  128. }