TdgyController.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.siwei.apply.controller;
  2. import com.siwei.apply.domain.Tdgy;
  3. import com.siwei.apply.service.TdgyService;
  4. import com.siwei.common.core.domain.R;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.*;
  7. import java.util.HashMap;
  8. import java.util.Map;
  9. /**
  10. * 土地供应 控制器
  11. * 单独选址第三步
  12. * 批次跑批第二步
  13. */
  14. @RestController
  15. @RequestMapping("/tdgy")
  16. public class TdgyController {
  17. @Autowired
  18. private TdgyService tdgyService;
  19. /**
  20. * 添加供地信息
  21. */
  22. @PostMapping()
  23. public R<Map> add(@RequestBody Tdgy tdgy) {
  24. try {
  25. String id = tdgyService.add(tdgy);
  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<Tdgy> get(@PathVariable("id") String id) {
  38. try {
  39. Tdgy tdgy = tdgyService.get(id);
  40. return R.ok(tdgy);
  41. } catch (Exception e) {
  42. return R.fail(e.getMessage());
  43. }
  44. }
  45. /**
  46. * 更新供地信息(按非空字段更新)
  47. */
  48. @PutMapping("")
  49. public R<Void> update(@RequestBody Tdgy tdgy) {
  50. try {
  51. tdgyService.update(tdgy);
  52. return R.ok();
  53. } catch (Exception e) {
  54. return R.fail(e.getMessage());
  55. }
  56. }
  57. }