LandOneCodeController.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package com.siwei.apply.controller;
  2. import com.siwei.apply.domain.LandOneCode;
  3. import com.siwei.apply.service.LandOneCodeService;
  4. import com.siwei.common.core.domain.R;
  5. import com.siwei.common.core.web.controller.BaseController;
  6. import lombok.RequiredArgsConstructor;
  7. import org.springframework.web.bind.annotation.*;
  8. import java.util.HashMap;
  9. import java.util.Map;
  10. /**
  11. * 土地统一编码 控制器
  12. * 提供基础的增删改查接口
  13. */
  14. @RestController
  15. @RequestMapping("/landOneCode")
  16. @RequiredArgsConstructor
  17. public class LandOneCodeController extends BaseController {
  18. private final LandOneCodeService service;
  19. /**
  20. * 新增
  21. */
  22. @PostMapping()
  23. public R<Map<String, String>> add(@RequestBody LandOneCode body) {
  24. try {
  25. String id = service.add(body);
  26. Map<String, String> map = new HashMap<>();
  27. map.put("id", id);
  28. return R.ok(map);
  29. } catch (Exception e) {
  30. return R.fail(e.getMessage());
  31. }
  32. }
  33. /**
  34. * 按ID查询
  35. */
  36. @GetMapping("/{id}")
  37. public R<LandOneCode> getById(@PathVariable String id) {
  38. try {
  39. return R.ok(service.getById(id));
  40. } catch (Exception e) {
  41. return R.fail(e.getMessage());
  42. }
  43. }
  44. /**
  45. * 更新(按ID)
  46. */
  47. @PutMapping()
  48. public R<Void> update(@RequestBody LandOneCode body) {
  49. try {
  50. service.update(body);
  51. return R.ok();
  52. } catch (Exception e) {
  53. return R.fail(e.getMessage());
  54. }
  55. }
  56. /**
  57. * 删除(按ID)
  58. */
  59. @DeleteMapping("/{id}")
  60. public R<Void> delete(@PathVariable String id) {
  61. try {
  62. service.deleteById(id);
  63. return R.ok();
  64. } catch (Exception e) {
  65. return R.fail(e.getMessage());
  66. }
  67. }
  68. @PostMapping("/addEntity")
  69. public R<String> addEntity(@RequestBody LandOneCode body) {
  70. try {
  71. service.addOrUpdateLandOneCodeInfo(body.getProjectWorkflowId());
  72. return R.ok(body.getProjectWorkflowId());
  73. } catch (Exception e) {
  74. return R.fail(e.getMessage());
  75. }
  76. }
  77. }