From 636fb51c032a8d306cce7f10cfac071623f2126f Mon Sep 17 00:00:00 2001 From: unknown <736250432@qq.com> Date: Wed, 30 Aug 2023 22:36:10 +0800 Subject: [PATCH] update --- .../controller/vehicle/VehicleController.php | 28 --------------- app/adminapi/lists/vehicle/VehicleLists.php | 10 +++--- app/adminapi/logic/vehicle/VehicleLogic.php | 35 ++----------------- .../validate/vehicle/VehicleValidate.php | 28 ++++----------- app/common/model/vehicle/Vehicle.php | 10 ++---- 5 files changed, 15 insertions(+), 96 deletions(-) diff --git a/app/adminapi/controller/vehicle/VehicleController.php b/app/adminapi/controller/vehicle/VehicleController.php index 0cf26fa1..4652d47f 100644 --- a/app/adminapi/controller/vehicle/VehicleController.php +++ b/app/adminapi/controller/vehicle/VehicleController.php @@ -1,18 +1,4 @@ post()->goCheck('delete'); - VehicleLogic::delete($params); - return $this->success('删除成功', [], 1, 1); - } - - /** * @notes 获取详情 * @return \think\response\Json diff --git a/app/adminapi/lists/vehicle/VehicleLists.php b/app/adminapi/lists/vehicle/VehicleLists.php index 1bb71e61..6ee6b5cd 100644 --- a/app/adminapi/lists/vehicle/VehicleLists.php +++ b/app/adminapi/lists/vehicle/VehicleLists.php @@ -28,7 +28,7 @@ class VehicleLists extends BaseAdminDataLists implements ListsSearchInterface { return [ '%like%' => ['gps_imei'], - '=' => ['license','status','type','is_check'], + '=' => ['license','status','type'], ]; } @@ -44,16 +44,14 @@ class VehicleLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - return Vehicle::where($this->searchWhere)->where('is_del',1) - ->field(['id','company_id','license', 'gps_imei', 'status','type','is_check']) + return Vehicle::where($this->searchWhere) + ->field(['id','license', 'gps_imei', 'status','type']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() ->each(function($item){ $item['status_name'] = $item->status_name; $item['type_name'] = $item->type_name; - $item['is_check_name'] = $item->is_check_name; - $item['company_name'] = Platform::where('id',$item['company_id'])->column('company_name')[0]; return $item; }) ->toArray(); @@ -68,7 +66,7 @@ class VehicleLists extends BaseAdminDataLists implements ListsSearchInterface */ public function count(): int { - return Vehicle::where($this->searchWhere)->where('is_del',1)->count(); + return Vehicle::where($this->searchWhere)->count(); } } \ No newline at end of file diff --git a/app/adminapi/logic/vehicle/VehicleLogic.php b/app/adminapi/logic/vehicle/VehicleLogic.php index 0723a2f8..416ee570 100644 --- a/app/adminapi/logic/vehicle/VehicleLogic.php +++ b/app/adminapi/logic/vehicle/VehicleLogic.php @@ -26,13 +26,10 @@ class VehicleLogic extends BaseLogic Db::startTrans(); try { Vehicle::create([ - 'company_id' => $params['company_id'], 'license' => $params['license'], 'gps_imei' => $params['gps_imei'], - 'type' => 1, - 'status' => 1, - 'is_del' => 1, - 'is_check' => 2, + 'type' => 0, + 'status' => 0, ]); Db::commit(); return true; @@ -56,12 +53,10 @@ class VehicleLogic extends BaseLogic Db::startTrans(); try { Vehicle::where('id', $params['id'])->update([ - 'company_id' => $params['company_id'], 'license' => $params['license'], 'gps_imei' => $params['gps_imei'], 'type' => $params['type'], 'status' => $params['status'], - 'is_check' => $params['is_check'] ]); Db::commit(); return true; @@ -72,30 +67,6 @@ class VehicleLogic extends BaseLogic } } - - /** - * @notes 删除 - * @param array $params - * @return bool - * @author likeadmin - * @date 2023/08/17 09:23 - */ - public static function delete(array $params): bool - { - try { - $data = Vehicle::where('id', $params['id'])->find(); - if($data['is_del'] !== 1){ - return false; - } - Vehicle::where('id', $params['id'])->update(['is_del' => 2]); - return true; - }catch (\Exception $e){ - self::setError($e->getMessage()); - return false; - } - } - - /** * @notes 获取详情 * @param $params @@ -105,7 +76,7 @@ class VehicleLogic extends BaseLogic */ public static function detail($params): array { - $data = Vehicle::where('is_del',1)->findOrEmpty($params['id']); + $data = Vehicle::findOrEmpty($params['id']); return $data->toArray(); } } \ No newline at end of file diff --git a/app/adminapi/validate/vehicle/VehicleValidate.php b/app/adminapi/validate/vehicle/VehicleValidate.php index caadc34b..89703730 100644 --- a/app/adminapi/validate/vehicle/VehicleValidate.php +++ b/app/adminapi/validate/vehicle/VehicleValidate.php @@ -31,12 +31,10 @@ class VehicleValidate extends BaseValidate */ protected $rule = [ 'id' => 'require', - 'company_id' => 'require|integer', 'license' => 'require|unique:vehicle', 'gps_imei' => 'require|number|unique:vehicle', - 'type' => 'require|in:1,2', - 'status' => 'require|in:1,2', - 'is_check' => 'require|in:1,2', + 'type' => 'require|in:0,1', + 'status' => 'require|in:0,1,2', ]; @@ -46,12 +44,10 @@ class VehicleValidate extends BaseValidate */ protected $field = [ 'id' => 'id', - 'company_id' => '所属公司', 'license' => '车辆牌照', 'gps_imei' => 'gps定位器设备标志', - 'type' => '车辆类型:1:平台自营 2:社会车辆', - 'status' => '车辆状态:1:未出租 2:已出租', - 'is_check' => '是否审核:1:未审核 2:已审核', + 'type' => '车辆类型:0:平台自营 1:社会车辆', + 'status' => '车辆状态:0:未出租 1:签约中 2:已出租', ]; @@ -63,7 +59,7 @@ class VehicleValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['company_id','license','gps_imei']); + return $this->only(['license','gps_imei','type','status']); } @@ -75,19 +71,7 @@ class VehicleValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','company_id','license','gps_imei','status','type','is_check'])->remove('license', 'unique')->remove('gps_imei', 'unique'); - } - - - /** - * @notes 删除场景 - * @return VehicleValidate - * @author likeadmin - * @date 2023/08/17 09:23 - */ - public function sceneDelete() - { - return $this->only(['id']); + return $this->only(['id','license','gps_imei','status','type'])->remove('license', 'unique')->remove('gps_imei', 'unique'); } diff --git a/app/common/model/vehicle/Vehicle.php b/app/common/model/vehicle/Vehicle.php index 960a8796..f8828cd8 100644 --- a/app/common/model/vehicle/Vehicle.php +++ b/app/common/model/vehicle/Vehicle.php @@ -15,19 +15,13 @@ class Vehicle extends BaseModel public function getStatusNameAttr($value,$data): string { - $status = [1=>'未出租',2=>'已出租']; + $status = [0=>'未出租',1=>'签约中',2=>'已出租']; return $status[$data['status']]; } public function getTypeNameAttr($value,$data): string { - $type = [1=>'平台车辆',2=>'社会车辆']; + $type = [0=>'平台车辆',1=>'社会车辆']; return $type[$data['type']]; } - - public function getIsCheckNameAttr($value,$data): string - { - $is_check = [1=>'未审核',2=>'已审核']; - return $is_check[$data['is_check']]; - } } \ No newline at end of file