This commit is contained in:
unknown 2023-08-30 22:36:10 +08:00
parent b608079600
commit 636fb51c03
5 changed files with 15 additions and 96 deletions

View File

@ -1,18 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\vehicle;
@ -75,20 +61,6 @@ class VehicleController extends BaseAdminController
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/17 09:23
*/
public function delete()
{
$params = (new VehicleValidate())->post()->goCheck('delete');
VehicleLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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');
}

View File

@ -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']];
}
}