FarmLandController.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. $order = $request->get('order', 'desc');
  30. $field = $field ?? 'land_add_time';
  31. $query = $this->doSelect($where, $field, $order);
  32. return $this->doFormat($query, $format, $limit);
  33. }
  34. /**
  35. * @Desc 查询后数据处理
  36. * @Author Gorden
  37. * @Date 2024/3/22 10:56
  38. *
  39. * @param $items
  40. * @return mixed
  41. */
  42. public function afterQuery($items)
  43. {
  44. foreach ($items as &$item){
  45. $item->land_long = rtrim($item->land_long,'0');
  46. $item->land_lat = rtrim($item->land_lat,'0');
  47. }
  48. return $items;
  49. }
  50. /**
  51. * @Desc 详情数据处理
  52. * @Author Gorden
  53. * @Date 2024/3/22 10:48
  54. *
  55. * @param $data
  56. * @return mixed
  57. */
  58. public function afterInfoQuery($data)
  59. {
  60. $data['land_long'] = rtrim($data['land_long'],'0');
  61. $data['land_lat'] = rtrim($data['land_lat'],'0');
  62. return $data;
  63. }
  64. /**
  65. * @Desc 删除
  66. * @Author Gorden
  67. * @Date 2024/2/27 14:49
  68. *
  69. * @param Request $request
  70. * @return Response
  71. * @throws \support\exception\BusinessException
  72. */
  73. public function delete(Request $request): Response
  74. {
  75. $ids = $this->deleteInput($request);
  76. $this->doSoftDelete($ids, ['land_is_del' => 1]);
  77. return json_success('success');
  78. }
  79. }