mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 17:07:49 +08:00
fix : update path And request
This commit is contained in:
114
app/Request/Admin/AdminMenuRequest.php
Normal file
114
app/Request/Admin/AdminMenuRequest.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class AdminMenuRequest 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 [
|
||||
'parent_id' => 'sometimes|integer',
|
||||
'name' => 'required|string|max:255',
|
||||
'path' => 'sometimes|string|max:255',
|
||||
'component' => 'sometimes|string|max:255',
|
||||
'redirect' => 'sometimes|string|max:255',
|
||||
'status' => 'sometimes|integer',
|
||||
'sort' => 'sometimes|integer',
|
||||
'remark' => 'sometimes|string|max:255',
|
||||
'meta.title' => 'required|string|max:255',
|
||||
'meta.i18n' => 'sometimes|string|max:255',
|
||||
'meta.badge' => 'sometimes|string|max:255',
|
||||
'meta.link' => 'sometimes|string|max:255',
|
||||
'meta.icon' => 'sometimes|string|max:255',
|
||||
'meta.affix' => 'sometimes|boolean',
|
||||
'meta.hidden' => 'sometimes|boolean',
|
||||
'meta.type' => 'sometimes|string|max:255',
|
||||
'meta.cache' => 'sometimes|boolean',
|
||||
'meta.breadcrumbEnable' => 'sometimes|boolean',
|
||||
'meta.copyright' => 'sometimes|boolean',
|
||||
'meta.componentPath' => 'sometimes|string|max:64',
|
||||
'meta.componentSuffix' => 'sometimes|string|max:4',
|
||||
'meta.activeName' => 'sometimes|string|max:255',
|
||||
'btnPermission' => 'sometimes|array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array|array[]
|
||||
*/
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'parent_id',
|
||||
'name',
|
||||
'path',
|
||||
'component',
|
||||
'redirect',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
'meta.title',
|
||||
'meta.i18n',
|
||||
'meta.badge',
|
||||
'meta.link',
|
||||
'meta.icon',
|
||||
'meta.affix',
|
||||
'meta.hidden',
|
||||
'meta.type',
|
||||
'meta.cache',
|
||||
'meta.breadcrumbEnable',
|
||||
'meta.copyright',
|
||||
'meta.componentPath',
|
||||
'meta.componentSuffix',
|
||||
'meta.activeName',
|
||||
'btnPermission',
|
||||
],
|
||||
'create' => [
|
||||
'parent_id',
|
||||
'name',
|
||||
'path',
|
||||
'component',
|
||||
'redirect',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
'meta.title',
|
||||
'meta.i18n',
|
||||
'meta.badge',
|
||||
'meta.link',
|
||||
'meta.icon',
|
||||
'meta.affix',
|
||||
'meta.hidden',
|
||||
'meta.type',
|
||||
'meta.cache',
|
||||
'meta.breadcrumbEnable',
|
||||
'meta.copyright',
|
||||
'meta.componentPath',
|
||||
'meta.componentSuffix',
|
||||
'meta.activeName',
|
||||
'btnPermission',
|
||||
],
|
||||
];
|
||||
}
|
||||
79
app/Request/Admin/AdminRoleRequest.php
Normal file
79
app/Request/Admin/AdminRoleRequest.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use App\Common\Trait\HttpMethodTrait;
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class AdminRoleRequest extends FormRequest
|
||||
{
|
||||
use HttpMethodTrait;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:60',
|
||||
'code' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:60',
|
||||
'regex:/^[a-zA-Z0-9_]+$/',
|
||||
],
|
||||
'status' => 'sometimes|integer|in:1,2',
|
||||
'sort' => 'required|integer',
|
||||
'remark' => 'nullable|string|max:255',
|
||||
'permissions' => 'sometimes|array',
|
||||
'permissions.*' => 'string|exists:menu,name',
|
||||
];
|
||||
if ($this->isCreate()) {
|
||||
$rules['code'][] = 'unique:role,code';
|
||||
}
|
||||
if ($this->isUpdate()) {
|
||||
$rules['code'][] = 'unique:role,code,' . $this->route('id');
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'code',
|
||||
'name',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
],
|
||||
'create' => [
|
||||
'code',
|
||||
'name',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
],
|
||||
'batch_grant_permission' => [
|
||||
'permissions',
|
||||
'permissions.*',
|
||||
]
|
||||
];
|
||||
}
|
||||
81
app/Request/Admin/AdminUserRequest.php
Normal file
81
app/Request/Admin/AdminUserRequest.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class AdminUserRequest 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 [
|
||||
'username' => 'required|string|max:20',
|
||||
'user_type' => 'required|integer',
|
||||
'nickname' => ['required', 'string', 'max:60', 'regex:/^[^\s]+$/'],
|
||||
'phone' => 'sometimes|string|max:12',
|
||||
'email' => 'sometimes|string|max:60|email:rfc,dns',
|
||||
'avatar' => 'sometimes|string|max:255|url',
|
||||
'signed' => 'sometimes|string|max:255',
|
||||
'status' => 'sometimes|integer',
|
||||
'backend_setting' => 'sometimes|array|max:255',
|
||||
'remark' => 'sometimes|string|max:255',
|
||||
'password' => 'sometimes|string|min:6|max:20',
|
||||
'role_codes' => 'required|array',
|
||||
'role_codes.*' => 'string|exists:role,code',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'username',
|
||||
'user_type',
|
||||
'nickname',
|
||||
'phone',
|
||||
'email',
|
||||
'avatar',
|
||||
'signed',
|
||||
'status',
|
||||
'backend_setting',
|
||||
'remark',
|
||||
'password',
|
||||
],
|
||||
'create' => [
|
||||
'username',
|
||||
'user_type',
|
||||
'nickname',
|
||||
'phone',
|
||||
'email',
|
||||
'avatar',
|
||||
'signed',
|
||||
'status',
|
||||
'backend_setting',
|
||||
'remark',
|
||||
'password',
|
||||
],
|
||||
'batch_grant_role' => [
|
||||
'role_codes',
|
||||
'role_codes.*',
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -22,7 +22,20 @@ class LoginRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
||||
'username' => 'required|string|exists:admin_user,username',
|
||||
'password' => 'required|string'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
protected array $scenes = [
|
||||
'login' => ['username', 'password'],
|
||||
];
|
||||
}
|
||||
|
||||
57
app/Request/Admin/PermissionRequest.php
Normal file
57
app/Request/Admin/PermissionRequest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class PermissionRequest 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 [
|
||||
'nickname' => 'sometimes|string|max:255',
|
||||
'new_password' => 'sometimes|confirmed|string|min:8',
|
||||
'new_password_confirmation' => 'sometimes|string|min:8',
|
||||
'old_password' => ['sometimes', 'string'],
|
||||
'avatar' => 'sometimes|string|max:255',
|
||||
'signed' => 'sometimes|string|max:255',
|
||||
'backend_setting' => 'sometimes|array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array|array[]
|
||||
*/
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'nickname',
|
||||
'new_password',
|
||||
'new_password_confirmation',
|
||||
'old_password',
|
||||
'avatar',
|
||||
'signed',
|
||||
'backend_setting',
|
||||
],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user