8ff1c9eb230f887898e29abbb45daab47de41fd5.svn-base 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package cn.com.goldenwater.dcproj.controller.wr;
  2. import cn.com.goldenwater.dcproj.model.WrSwsB;
  3. import cn.com.goldenwater.dcproj.param.WrSwsBParam;
  4. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  5. import cn.com.goldenwater.dcproj.service.WrSwsBService;
  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/wrSwsB")
  32. public class WrSwsBController extends BaseController {
  33. private Logger logger = LoggerFactory.getLogger(getClass());
  34. @Autowired
  35. private WrSwsBService wrSwsBService;
  36. @Autowired
  37. private OlBisInspOrgService olBisInspOrgService;
  38. @ApiOperation(value = "添加")
  39. @RequestMapping(value = "/insert", method = RequestMethod.POST)
  40. public BaseResponse<JSONObject> insert(@ApiParam(name = "wrSwsB", value = "WrSwsB", required = true) @RequestBody WrSwsB wrSwsB) {
  41. String uuid = "";
  42. JSONObject json = new JSONObject();
  43. try {
  44. uuid = wrSwsBService.add(wrSwsB);
  45. json.put("id", uuid);
  46. } catch (Exception e) {
  47. e.printStackTrace();
  48. logger.error(e.getMessage());
  49. return buildFailResponse(e.getMessage());
  50. }
  51. return buildSuccessResponse(json);
  52. }
  53. @ApiOperation(value = "根据ID删除")
  54. @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  55. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  56. int ret = wrSwsBService.delete(id);
  57. JSONObject json = new JSONObject();
  58. json.put("code", ret);
  59. return buildSuccessResponse(json);
  60. }
  61. @ApiOperation(value = "更新信息")
  62. @RequestMapping(value = "/update", method = RequestMethod.PUT)
  63. public BaseResponse update(@ApiParam(name = "wrSwsB", value = "WrSwsB", required = true) @RequestBody WrSwsB wrSwsB) {
  64. int ret = 0;
  65. try {
  66. ret = wrSwsBService.modify(wrSwsB);
  67. } catch (Exception e) {
  68. e.printStackTrace();
  69. logger.error(e.getMessage());
  70. return buildFailResponse(e.getMessage());
  71. }
  72. return buildSuccessResponse(wrSwsB);
  73. }
  74. @ApiOperation(value = "根据ID获取(单表)")
  75. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  76. public BaseResponse<WrSwsB> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  77. WrSwsB wrSwsB = wrSwsBService.get(id);
  78. return buildSuccessResponse(wrSwsB);
  79. }
  80. @ApiOperation(value = "获取列表(分页)")
  81. @RequestMapping(value = "/queryListByPage", method = {RequestMethod.POST})
  82. public BaseResponse<PageInfo<WrSwsB>> queryListByPage(@RequestBody WrSwsBParam param) {
  83. PageInfo<WrSwsB> list = new PageInfo<>();
  84. param.setProvince(AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId())));
  85. try {
  86. if (StringUtils.isNotBlank(param.getAdCode())) {
  87. String adCode = param.getAdCode();
  88. if (adCode.contains("00")) {
  89. adCode = adCode.replace("00", "");
  90. param.setAdCode(adCode);
  91. }
  92. }
  93. list = wrSwsBService.queryListByPage(param);
  94. } catch (Exception e) {
  95. e.printStackTrace();
  96. logger.error(e.getMessage());
  97. return buildFailResponse(e.getMessage());
  98. }
  99. return buildSuccessResponse(list);
  100. }
  101. @ApiOperation(value = "获取列表")
  102. @RequestMapping(value = "/queryList", method = {RequestMethod.POST})
  103. public BaseResponse<List<WrSwsB>> queryList(@RequestBody WrSwsBParam param) {
  104. List<WrSwsB> list = new ArrayList<>();
  105. try {
  106. list = wrSwsBService.queryList(param);
  107. } catch (Exception e) {
  108. e.printStackTrace();
  109. logger.error(e.getMessage());
  110. return buildFailResponse(e.getMessage());
  111. }
  112. return buildSuccessResponse(list);
  113. }
  114. @ApiOperation(value = "获取一个对象")
  115. @RequestMapping(value = "/getBy", method = {RequestMethod.POST})
  116. public BaseResponse<WrSwsB> getBy(@RequestBody WrSwsBParam param) {
  117. WrSwsB one = new WrSwsB();
  118. try {
  119. one = wrSwsBService.getBy(param);
  120. } catch (Exception e) {
  121. e.printStackTrace();
  122. logger.error(e.getMessage());
  123. return buildFailResponse(e.getMessage());
  124. }
  125. return buildSuccessResponse(one);
  126. }
  127. }