68fff4b4529d1a2df4a25e57b4ae5b8a7c2b1c0e.svn-base 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package cn.com.goldenwater.dcproj.controller.base;
  2. import cn.com.goldenwater.dcproj.model.AttBasBase;
  3. import cn.com.goldenwater.dcproj.param.AttBasBaseParam;
  4. import cn.com.goldenwater.dcproj.service.AttBasBaseService;
  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 com.github.pagehelper.PageInfo;
  12. import org.slf4j.Logger;
  13. import org.slf4j.LoggerFactory;
  14. import org.springframework.beans.factory.annotation.Autowired;
  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. import java.util.List;
  21. /**
  22. * @author lune
  23. * @date 2019-7-30
  24. */
  25. @Api(value = "ATT 流域机构表管理", tags = "ATT 流域机构表管理")
  26. @RestController
  27. @RequestMapping("/att/bas/base")
  28. public class AttBasBaseController extends BaseController {
  29. private Logger logger = LoggerFactory.getLogger(getClass());
  30. @Autowired
  31. private AttBasBaseService attBasBaseService;
  32. @ApiOperation(value = "添加/修改流域机构表")
  33. @RequestMapping(value = "", method = RequestMethod.POST)
  34. public BaseResponse<AttBasBase> insert(@ApiParam(name = "attBasBase", value = "AttBasBase", required = true) @RequestBody AttBasBase attBasBase) {
  35. if (StringUtils.isBlank(attBasBase.getBasCode())) {
  36. int count = attBasBaseService.selectMax();
  37. count++;
  38. if (String.valueOf(count).length() == 4) {
  39. attBasBase.setBasCode("00" + count);
  40. }
  41. if (String.valueOf(count).length() == 5) {
  42. attBasBase.setBasCode("0" + count);
  43. }
  44. if (String.valueOf(count).length() == 6) {
  45. attBasBase.setBasCode("" + count);
  46. }
  47. attBasBaseService.insert(attBasBase);
  48. } else {
  49. attBasBaseService.update(attBasBase);
  50. }
  51. return buildSuccessResponse(attBasBase);
  52. }
  53. @ApiOperation(value = "根据ID删除流域机构表")
  54. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  55. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  56. int ret = attBasBaseService.delete(id);
  57. return buildSuccessResponse();
  58. }
  59. @ApiOperation(value = "根据ID获取流域机构表(单表)")
  60. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  61. public BaseResponse<AttBasBase> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  62. AttBasBase attBasBase = attBasBaseService.get(id);
  63. return buildSuccessResponse(attBasBase);
  64. }
  65. @ApiOperation(value = "获取流域机构表(列表所有)")
  66. @RequestMapping(value = "/list", method = RequestMethod.POST)
  67. public BaseResponse<List<AttBasBase>> list(@ApiParam(name = "attBasBaseParam", value = "attBasBaseParam", required = true) @RequestBody AttBasBaseParam attBasBaseParam) {
  68. List<AttBasBase> attBasBaseList = attBasBaseService.findList(attBasBaseParam);
  69. return buildSuccessResponse(attBasBaseList);
  70. }
  71. @ApiOperation(value = "获取流域机构表(列表--分页)")
  72. @RequestMapping(value = "/page", method = RequestMethod.POST)
  73. public BaseResponse<PageInfo<AttBasBase>> page(@ApiParam(name = "attBasBaseParam", value = "attBasBaseParam", required = true) @RequestBody AttBasBaseParam attBasBaseParam) {
  74. PageInfo<AttBasBase> attBasBaseList = attBasBaseService.findPageInfo(attBasBaseParam);
  75. return buildSuccessResponse(attBasBaseList);
  76. }
  77. }