1
0

TdhyhsController.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package com.siwei.apply.controller;
  2. import com.siwei.apply.domain.res.TdhyhsRes;
  3. import com.siwei.apply.domain.res.TdhyhsSinglRes;
  4. import com.siwei.apply.domain.vo.OnChainVo;
  5. import com.siwei.apply.domain.vo.TdhyhsUpdateVo;
  6. import com.siwei.apply.domain.vo.TdhyhsVo;
  7. import com.siwei.apply.service.TdhyhsService;
  8. import com.siwei.common.core.domain.R;
  9. import com.siwei.common.core.web.controller.BaseController;
  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. /**
  15. * 土地核验与规划核实 控制器
  16. * 单独选址第七步
  17. * 批次跑批第六步
  18. */
  19. @RestController
  20. @RequestMapping("/tdhyhs")
  21. public class TdhyhsController extends BaseController {
  22. @Autowired
  23. private TdhyhsService tdhyhsService;
  24. /**
  25. * 添加土地核验与规划核实
  26. */
  27. @PostMapping()
  28. public R<Map> Add(@RequestBody TdhyhsVo tdhyhsVo) {
  29. try {
  30. // Boolean b = tdhyhsService.isExit(tdhyhsVo.getProjectId());
  31. // if (b == true) {
  32. // return R.fail("此项目已添加土地核验与规划核实");
  33. // }
  34. String id = tdhyhsService.add(tdhyhsVo);
  35. Map<String, String> map = new HashMap<>();
  36. map.put("id", id);
  37. return R.ok(map);
  38. } catch (Exception e) {
  39. return R.fail(e.getMessage());
  40. }
  41. }
  42. /**
  43. * 获取土地核验与规划核实
  44. *
  45. * @param projectId 项目ID
  46. * @return 土地核验与规划核实
  47. */
  48. @GetMapping("/{projectId}")
  49. public R<TdhyhsRes> Get(@PathVariable String projectId) {
  50. try {
  51. return R.ok(tdhyhsService.get(projectId));
  52. } catch (Exception e) {
  53. return R.fail(e.getMessage());
  54. }
  55. }
  56. /**
  57. * 通过主键id获取土地核验与规划核实,返回结果与按projectId查询一致(单条结构)
  58. */
  59. @GetMapping("/id/{id}")
  60. public R<TdhyhsSinglRes> GetById(@PathVariable String id) {
  61. try {
  62. return R.ok(tdhyhsService.getById(id));
  63. } catch (Exception e) {
  64. return R.fail(e.getMessage());
  65. }
  66. }
  67. /**
  68. * 更新土地核验与规划核实
  69. *
  70. * @param tdhyhsUpdateVo 土地核验与规划核实
  71. * @return 操作结果
  72. */
  73. @PutMapping()
  74. public R<Void> Update(@RequestBody TdhyhsUpdateVo tdhyhsUpdateVo) {
  75. try {
  76. tdhyhsService.update(tdhyhsUpdateVo);
  77. return R.ok();
  78. } catch (Exception e) {
  79. return R.fail(e.getMessage());
  80. }
  81. }
  82. /**
  83. * 更新土地核验与规划核实的上链状态
  84. */
  85. @PutMapping("/onchain")
  86. public R<Void> updateHasOnchain(@RequestBody OnChainVo onChainVo) {
  87. try {
  88. for (String id : onChainVo.getIds()) {
  89. tdhyhsService.updateHasOnchain(id, onChainVo.getHasOnchain());
  90. }
  91. return R.ok();
  92. } catch (Exception e) {
  93. return R.fail(e.getMessage());
  94. }
  95. }
  96. }