feat : driver
This commit is contained in:
@@ -4,8 +4,14 @@ namespace App\Constants\Common;
|
|||||||
|
|
||||||
class RoleCode
|
class RoleCode
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var int 角色 1=超级管理员 2=管理员 3=财务 5=客服 6=市场部 7=厨师 8=司机
|
||||||
|
*/
|
||||||
const int SUPER_ADMIN = 1;
|
const int SUPER_ADMIN = 1;
|
||||||
const int ADMIN = 2;
|
const int ADMIN = 2;
|
||||||
const int CHEF = 3;
|
const int FINANCE = 3;
|
||||||
const int DRIVER = 4;
|
const int CUSTOMER_SERVICE = 5;
|
||||||
|
const int MARKETPLACE = 6;
|
||||||
|
const int CHEF = 7;
|
||||||
|
const int DRIVER = 8;
|
||||||
}
|
}
|
||||||
33
app/Controller/Admin/DriverController.php
Normal file
33
app/Controller/Admin/DriverController.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
|
use App\Request\Admin\DriverRequest;
|
||||||
|
use App\Request\Admin\SiteRequest;
|
||||||
|
use App\Service\Admin\System\DriverService;
|
||||||
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
|
use Hyperf\HttpServer\Annotation\Middlewares;
|
||||||
|
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||||
|
use Hyperf\Validation\Annotation\Scene;
|
||||||
|
|
||||||
|
#[Controller(prefix: "admin/driver")]
|
||||||
|
#[Middlewares([
|
||||||
|
JwtAuthMiddleware::class,
|
||||||
|
])]
|
||||||
|
class DriverController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 司机列表
|
||||||
|
* @param DriverRequest $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: "driver_list", methods: "GET")]
|
||||||
|
#[Scene(scene: "driver_list")]
|
||||||
|
public function driverList(DriverRequest $request)
|
||||||
|
{
|
||||||
|
return (new DriverService())->driverList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,15 +53,4 @@ class SiteController
|
|||||||
return (new SiteService)->info();
|
return (new SiteService)->info();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 司机列表
|
|
||||||
* @param SiteRequest $request
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
#[RequestMapping(path: "driver_list", methods: "GET")]
|
|
||||||
#[Scene(scene: "driver_list")]
|
|
||||||
public function driverList(SiteRequest $request)
|
|
||||||
{
|
|
||||||
return (new SiteService)->driverList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
45
app/Request/Admin/DriverRequest.php
Normal file
45
app/Request/Admin/DriverRequest.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Request\Admin;
|
||||||
|
|
||||||
|
use Hyperf\Validation\Request\FormRequest;
|
||||||
|
|
||||||
|
class DriverRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'query_driver_name' =>'sometimes|string',
|
||||||
|
'query_driver_city_id' => 'sometimes|integer|exists:system_city,id',
|
||||||
|
'query_driver_id' =>'sometimes|integer|exists:admin_user,id',
|
||||||
|
'limit' => 'required|integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected array $scenes = [
|
||||||
|
'driver_list' => [
|
||||||
|
'limit',
|
||||||
|
'query_driver_name',
|
||||||
|
'query_driver_city_id',
|
||||||
|
'query_driver_id'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -43,8 +43,9 @@ class SiteRequest extends FormRequest
|
|||||||
'query_kitchen_id' =>'sometimes|integer|exists:kitchen,id',
|
'query_kitchen_id' =>'sometimes|integer|exists:kitchen,id',
|
||||||
'query_driver_id' =>'sometimes|integer|exists:admin_user,id',
|
'query_driver_id' =>'sometimes|integer|exists:admin_user,id',
|
||||||
'query_id' => 'sometimes|integer|exists:site,id',
|
'query_id' => 'sometimes|integer|exists:site,id',
|
||||||
'query_driver_name' =>'sometimes|string',
|
// 'query_driver_name' =>'sometimes|string',
|
||||||
'query_driver_city_id' => 'sometimes|integer|exists:system_city,id',
|
// 'query_driver_city_id' => 'sometimes|integer|exists:system_city,id',
|
||||||
|
'limit' => 'required|integer',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
77
app/Service/Admin/System/DriverService.php
Normal file
77
app/Service/Admin/System/DriverService.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This service file is part of item.
|
||||||
|
*
|
||||||
|
* @author ctexthuang
|
||||||
|
* @contact ctexthuang@qq.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Service\Admin\System;
|
||||||
|
|
||||||
|
use App\Constants\Admin\UserCode;
|
||||||
|
use App\Constants\Common\RoleCode;
|
||||||
|
use App\Model\AdminSection;
|
||||||
|
use App\Model\AdminUser;
|
||||||
|
use App\Service\Admin\BaseService;
|
||||||
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
|
||||||
|
class DriverService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 注入部门类
|
||||||
|
* @var AdminSection
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected readonly AdminSection $adminSectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var AdminUser
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected readonly AdminUser $adminUserModel;
|
||||||
|
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//todo Write logic
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 司机列表
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function driverList(): array
|
||||||
|
{
|
||||||
|
$limit = $this->request->input('limit', 10);
|
||||||
|
$cityId = (int)$this->request->input('query_driver_city_id',0);
|
||||||
|
$name = $this->request->input('query_driver_name');
|
||||||
|
|
||||||
|
// $where[] = [
|
||||||
|
// ['is_del', '=', UserCode::IS_NO_DEL],
|
||||||
|
// ['status','=',UserCode::ENABLE],
|
||||||
|
// ['role_id','=',RoleCode::DRIVER]
|
||||||
|
// ];
|
||||||
|
|
||||||
|
$list = $this
|
||||||
|
->adminUserModel
|
||||||
|
->where('is_del',UserCode::IS_NO_DEL)
|
||||||
|
->where('status',UserCode::ENABLE)
|
||||||
|
->where('role_id',RoleCode::DRIVER)
|
||||||
|
->when($name, function ($query) use ($name) {
|
||||||
|
$query->where('name', 'like', "$name%");
|
||||||
|
})
|
||||||
|
->when($cityId > 0, function ($query) use ($cityId) {
|
||||||
|
$query->whereIn('section_id', $this->adminSectionModel->getIdsByCityId($cityId));
|
||||||
|
})
|
||||||
|
->when($id = $this->request->input('query_driver_id'), function ($query) use ($id) {
|
||||||
|
$query->where('id', $id);
|
||||||
|
})
|
||||||
|
->paginate($limit,['chinese_name','id','mobile','status'])->toArray();
|
||||||
|
|
||||||
|
return $this->return->success('success',$list);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,14 +54,6 @@ class SiteService extends BaseService
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected readonly Kitchen $kitchenModel;
|
protected readonly Kitchen $kitchenModel;
|
||||||
|
|
||||||
/**
|
|
||||||
* 注入部门类
|
|
||||||
* @var AdminSection
|
|
||||||
*/
|
|
||||||
#[Inject]
|
|
||||||
protected readonly AdminSection $adminSectionModel;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
@@ -341,39 +333,4 @@ class SiteService extends BaseService
|
|||||||
return $this->return->success('success',$res);
|
return $this->return->success('success',$res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 司机列表
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function driverList(): array
|
|
||||||
{
|
|
||||||
$limit = $this->request->input('limit', 10);
|
|
||||||
$cityId = (int)$this->request->input('query_driver_city_id',0);
|
|
||||||
$name = $this->request->input('query_driver_name');
|
|
||||||
|
|
||||||
// $where[] = [
|
|
||||||
// ['is_del', '=', UserCode::IS_NO_DEL],
|
|
||||||
// ['status','=',UserCode::ENABLE],
|
|
||||||
// ['role_id','=',RoleCode::DRIVER]
|
|
||||||
// ];
|
|
||||||
|
|
||||||
$list = $this
|
|
||||||
->adminUserModel
|
|
||||||
->where('is_del',UserCode::IS_NO_DEL)
|
|
||||||
->where('status',UserCode::ENABLE)
|
|
||||||
->where('role_id',RoleCode::DRIVER)
|
|
||||||
->when($name, function ($query) use ($name) {
|
|
||||||
$query->where('name', 'like', "$name%");
|
|
||||||
})
|
|
||||||
->when($cityId > 0, function ($query) use ($cityId) {
|
|
||||||
$query->whereIn('section_id', $this->adminSectionModel->getIdsByCityId($cityId));
|
|
||||||
})
|
|
||||||
->when($id = $this->request->input('query_driver_id'), function ($query) use ($id) {
|
|
||||||
$query->where('id', $id);
|
|
||||||
})
|
|
||||||
->paginate($limit,['chinese_name','id','mobile','status'])->toArray();
|
|
||||||
|
|
||||||
return $this->return->success('success',$list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user