FarmLandController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\validate\life\FarmLandValidate;
  4. use app\controller\Curd;
  5. use app\model\FarmLand as FarmLandModel;
  6. use support\Request;
  7. use support\Response;
  8. class FarmLandController extends Curd
  9. {
  10. public function __construct()
  11. {
  12. $this->model = new FarmLandModel();
  13. $this->validate = true;
  14. $this->validateClass = new FarmLandValidate();
  15. }
  16. /**
  17. * @Desc 列表
  18. * @Author Gorden
  19. * @Date 2024/2/27 14:46
  20. *
  21. * @param Request $request
  22. * @return Response
  23. * @throws \support\exception\BusinessException
  24. */
  25. public function select(Request $request): Response
  26. {
  27. [$where, $format, $limit, $field, $order] = $this->selectInput($request);
  28. $where['land_is_del'] = 0;
  29. $query = $this->doSelect($where, $field, $order);
  30. return $this->doFormat($query, $format, $limit);
  31. }
  32. /**
  33. * @Desc 查询后数据处理
  34. * @Author Gorden
  35. * @Date 2024/3/22 10:56
  36. *
  37. * @param $items
  38. * @return mixed
  39. */
  40. public function afterQuery($items)
  41. {
  42. foreach ($items as &$item){
  43. $item->land_long = rtrim($item->land_long,'0');
  44. $item->land_lat = rtrim($item->land_lat,'0');
  45. }
  46. return $items;
  47. }
  48. /**
  49. * @Desc 详情数据处理
  50. * @Author Gorden
  51. * @Date 2024/3/22 10:48
  52. *
  53. * @param $data
  54. * @return mixed
  55. */
  56. public function afterInfoQuery($data)
  57. {
  58. $data['land_long'] = rtrim($data['land_long'],'0');
  59. $data['land_lat'] = rtrim($data['land_lat'],'0');
  60. return $data;
  61. }
  62. /**
  63. * @Desc 删除
  64. * @Author Gorden
  65. * @Date 2024/2/27 14:49
  66. *
  67. * @param Request $request
  68. * @return Response
  69. * @throws \support\exception\BusinessException
  70. */
  71. public function delete(Request $request): Response
  72. {
  73. $ids = $this->deleteInput($request);
  74. $this->doSoftDelete($ids, ['land_is_del' => 1]);
  75. return json_success('success');
  76. }
  77. }