feat: 添加角色分页/详情/新增/更新/删除接口
This commit is contained in:
46
app/admin/validate/v1/SysRoleValidate.php
Normal file
46
app/admin/validate/v1/SysRoleValidate.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\validate\v1;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysRoleValidate extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'pid' => 'integer',
|
||||
'name' => 'max:64',
|
||||
'desc' => 'max:255',
|
||||
'menu_permission.*.menu_id' => 'integer',
|
||||
'menu_permission.*.permission' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'id.require' => '角色ID不能为空',
|
||||
'id.integer' => '角色ID必须为整数',
|
||||
'pid.integer' => '父级角色ID必须为整数',
|
||||
'name.max' => '角色名称最多64个字符',
|
||||
'desc.max' => '角色描述最多255个字符',
|
||||
'menu_permission.*.menu_id.integer' => '菜单ID必须为整数',
|
||||
'menu_permission.*.permission.array' => '权限必须为数组',
|
||||
];
|
||||
|
||||
// 新增场景校验
|
||||
public function sceneCreate()
|
||||
{
|
||||
return $this->remove('id', 'require|integer');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user