From ff4ead0156a65a73b694b084dbf89c0ee078dcda Mon Sep 17 00:00:00 2001 From: unknown <736250432@qq.com> Date: Sat, 26 Aug 2023 14:32:07 +0800 Subject: [PATCH] s --- app/api/controller/VehicleController.php | 17 ++++++++++++++++- app/api/route/app.php | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/api/controller/VehicleController.php b/app/api/controller/VehicleController.php index 8566ac53..6034596a 100644 --- a/app/api/controller/VehicleController.php +++ b/app/api/controller/VehicleController.php @@ -2,6 +2,7 @@ namespace app\api\controller; use app\api\logic\VehicleLogic; +use app\common\model\vehicle\Vehicle; use think\response\Json; /** @@ -11,7 +12,7 @@ use think\response\Json; */ class VehicleController extends BaseApiController { - public array $notNeedLogin = ['checkNum','vehicleRent','companyCarList','addVehicle','getCarLocal','getCarHistory']; + public array $notNeedLogin = ['checkNum','vehicleRent','companyCarList','addVehicle','getSelfCar','getCarLocal','getCarHistory']; //验证租赁数量 @@ -81,6 +82,20 @@ class VehicleController extends BaseApiController } } + public function getSelfCar():Json { + //获取参数 + $company_id = $this->request->post('company_id'); + if(empty($company_id)){ + return $this->fail('缺少必要参数'); + } + $car = Vehicle::field('id')->where('company_id',$company_id)->where('type',1)->find(); + if($car){ + return $this->success('请求成功',['has_car'=>true]); + }else{ + return $this->success('请求成功',['has_car'=>false]); + } + } + //获取车辆当前位置 public function getCarLocal():Json { $params = $this->request->get(['car_id']); diff --git a/app/api/route/app.php b/app/api/route/app.php index a6d04ce5..65b05828 100755 --- a/app/api/route/app.php +++ b/app/api/route/app.php @@ -30,4 +30,5 @@ Route::rule('vehicleRent','Vehicle/vehicleRent','post'); Route::rule('getCarLocal','Vehicle/getCarLocal','get'); Route::rule('getCarHistory','Vehicle/getCarHistory','get'); Route::rule('companyCarList','Vehicle/companyCarList','post'); -Route::rule('addVehicle','Vehicle/addVehicle','post'); \ No newline at end of file +Route::rule('addVehicle','Vehicle/addVehicle','post'); +Route::rule('getSelfCar','Vehicle/getSelfCar','post'); \ No newline at end of file