FarmLand.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\life\FarmLandServer;
  5. class FarmLand extends BaseController
  6. {
  7. /**
  8. * Notes:获取地块列表
  9. * @return \support\Response
  10. * User: YCP
  11. * Date: 2022/10/17
  12. */
  13. public function getlandList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = FarmLandServer::getlandList($page, $limit, $keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:获取所有
  22. * @return \support\Response
  23. * User: YCP
  24. * Date: 2022/10/17
  25. */
  26. public function getlandAll()
  27. {
  28. $result = FarmLandServer::getlandAll();
  29. return json_success($result, '成功');
  30. }
  31. /**
  32. * Notes:修改地块
  33. * @return \support\Response
  34. * User: YCP
  35. * Date: 2022/10/17
  36. */
  37. public function updateland()
  38. {
  39. $land_id = $this->request->post('land_id');
  40. $land_name = $this->request->post('land_name');
  41. $land_price = $this->request->post('land_price');
  42. $land_longitude = $this->request->post('land_longitude');
  43. $land_latitude = $this->request->post('land_latitude');
  44. $admin_id = $this->request->admin_id;
  45. $this->validateCheck('life\FarmLandValidate', ['land_id' => $land_id], 'update');
  46. $result = FarmLandServer::updateland($land_id, $land_name, $land_price, $land_longitude, $land_latitude, $admin_id);
  47. return json_success($result, '修改成功');
  48. }
  49. /**
  50. * Notes:删除地块
  51. * @return \support\Response
  52. * User: YCP
  53. * Date: 2022/10/17
  54. */
  55. public function delland()
  56. {
  57. $land_id = $this->request->get('land_id');
  58. $admin_id = $this->request->admin_id;
  59. $this->validateCheck('life\FarmLandValidate', ['land_id' => $land_id], 'info');
  60. $result = FarmLandServer::delland($land_id,$admin_id);
  61. if ($result){
  62. return json_success($result, '删除成功');
  63. }else{
  64. throw new \Exception('删除失败!');
  65. }
  66. }
  67. /**
  68. * Notes:添加地块
  69. * @return \support\Response
  70. * User: YCP
  71. * Date: 2022/10/17
  72. */
  73. public function addland()
  74. {
  75. $land_name = $this->request->post('land_name');
  76. $land_price = $this->request->post('land_price');
  77. $land_longitude = $this->request->post('land_longitude');
  78. $land_latitude = $this->request->post('land_latitude');
  79. $admin_id = $this->request->admin_id;
  80. $this->validateCheck('life\FarmLandValidate', ['land_name' => $land_name, 'land_price' => $land_price, 'land_longitude' => $land_longitude, 'land_latitude' => $land_latitude], 'create');
  81. $result = FarmLandServer::insertland($land_name, $land_price, $land_longitude, $land_latitude, $admin_id);
  82. return json_success($result, '添加成功');
  83. }
  84. /**
  85. * Notes:查询地块详情
  86. * @return \support\Response
  87. * User: YCP
  88. * Date: 2022/10/17
  89. */
  90. public function landInfo()
  91. {
  92. $land_id = $this->request->get('land_id');
  93. $this->validateCheck('life\FarmLandValidate', ['land_id' => $land_id], 'info');
  94. $result = FarmLandServer::landInfo($land_id);
  95. return json_success($result, '成功');
  96. }
  97. }