FarmLandController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. public function afterQuery($items)
  33. {
  34. foreach ($items as &$item){
  35. $item->land_long = rtrim($item->land_long,'0');
  36. $item->land_lat = rtrim($item->land_lat,'0');
  37. }
  38. return $items;
  39. }
  40. /**
  41. * @Desc 详情数据处理
  42. * @Author Gorden
  43. * @Date 2024/3/22 10:48
  44. *
  45. * @param $data
  46. * @return mixed
  47. */
  48. public function afterInfoQuery($data)
  49. {
  50. $data['land_long'] = rtrim($data['land_long'],'0');
  51. $data['land_lat'] = rtrim($data['land_lat'],'0');
  52. return $data;
  53. }
  54. /**
  55. * @Desc 删除
  56. * @Author Gorden
  57. * @Date 2024/2/27 14:49
  58. *
  59. * @param Request $request
  60. * @return Response
  61. * @throws \support\exception\BusinessException
  62. */
  63. public function delete(Request $request): Response
  64. {
  65. $ids = $this->deleteInput($request);
  66. $this->doSoftDelete($ids, ['land_is_del' => 1]);
  67. return json_success('success');
  68. }
  69. }