1
0

LandOneCodeController.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package com.siwei.apply.controller;
  2. import com.siwei.apply.domain.LandOneCode;
  3. import com.siwei.apply.domain.ProjectWorkflow;
  4. import com.siwei.apply.domain.vo.LandOneCodeVo;
  5. import com.siwei.apply.mapper.ProjectWorkflowMapper;
  6. import com.siwei.apply.service.LandOneCodeService;
  7. import com.siwei.common.core.domain.R;
  8. import com.siwei.common.core.web.controller.BaseController;
  9. import lombok.RequiredArgsConstructor;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.HashMap;
  13. import java.util.Map;
  14. import java.util.Objects;
  15. /**
  16. * 土地统一编码 控制器
  17. * 提供基础的增删改查接口
  18. */
  19. @RestController
  20. @RequestMapping("/landOneCode")
  21. @RequiredArgsConstructor
  22. public class LandOneCodeController extends BaseController {
  23. private final LandOneCodeService service;
  24. /**
  25. * 新增
  26. */
  27. @PostMapping()
  28. public R<Map<String, String>> add(@RequestBody LandOneCode body) {
  29. try {
  30. String id = service.add(body);
  31. Map<String, String> map = new HashMap<>();
  32. map.put("id", id);
  33. return R.ok(map);
  34. } catch (Exception e) {
  35. return R.fail(e.getMessage());
  36. }
  37. }
  38. /**
  39. * 按ID查询
  40. */
  41. @GetMapping("/{id}")
  42. public R<LandOneCode> getById(@PathVariable String id) {
  43. try {
  44. return R.ok(service.getById(id));
  45. } catch (Exception e) {
  46. return R.fail(e.getMessage());
  47. }
  48. }
  49. /**
  50. * 更新(按ID)
  51. */
  52. @PutMapping()
  53. public R<Void> update(@RequestBody LandOneCode body) {
  54. try {
  55. service.update(body);
  56. return R.ok();
  57. } catch (Exception e) {
  58. return R.fail(e.getMessage());
  59. }
  60. }
  61. /**
  62. * 删除(按ID)
  63. */
  64. @DeleteMapping("/{id}")
  65. public R<Void> delete(@PathVariable String id) {
  66. try {
  67. service.deleteById(id);
  68. return R.ok();
  69. } catch (Exception e) {
  70. return R.fail(e.getMessage());
  71. }
  72. }
  73. @PostMapping("/addEntity")
  74. public R<String> addEntity(@RequestBody LandOneCode body) {
  75. try {
  76. service.addOrUpdateLandOneCodeInfo(body.getProjectWorkflowId());
  77. return R.ok(body.getProjectWorkflowId());
  78. } catch (Exception e) {
  79. return R.fail(e.getMessage());
  80. }
  81. }
  82. @GetMapping("/getResourceCode")
  83. public R<LandOneCodeVo> getResourceCode(@RequestParam String projectId,@RequestParam String projectWorkflowId) {
  84. try {
  85. LandOneCodeVo landOneCodeVo = null;
  86. // projectWorkflowId 这里为节点id,前端兼容
  87. ProjectWorkflow projectWorkflow= service.getProjectWorkflowByNodeId(projectWorkflowId);
  88. if(Objects.nonNull(projectWorkflow)){
  89. projectWorkflowId=projectWorkflow.getId();
  90. landOneCodeVo = service.getLandOneCodeByWorkflowId(projectWorkflowId);
  91. }
  92. return R.ok(landOneCodeVo);
  93. } catch (Exception e) {
  94. return R.fail(e.getMessage());
  95. }
  96. }
  97. }