This commit is contained in:
37
app/Request/AbstractRequest.php
Normal file
37
app/Request/AbstractRequest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/3
|
||||
* Time: 下午8:22
|
||||
* Description:
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request;
|
||||
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/3
|
||||
* Time: 下午8:24
|
||||
* Description: 请求基类。
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
abstract class AbstractRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
51
app/Request/CompanyRequest.php
Normal file
51
app/Request/CompanyRequest.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/4
|
||||
* Time: 下午2:54
|
||||
* Description:
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request;
|
||||
|
||||
use App\Constants\ActiveStatusConst;
|
||||
use App\Constants\CompanyTypeConst;
|
||||
|
||||
class CompanyRequest extends AbstractRequest
|
||||
{
|
||||
public array $scenes = [
|
||||
'addCompany' => [
|
||||
'id',
|
||||
'company_type',
|
||||
'name',
|
||||
'status',
|
||||
],
|
||||
];
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'id' => 'integer',
|
||||
'company_type' => 'required|in:' . implode(',', array_column(CompanyTypeConst::getConstantsList(), 'value')),
|
||||
'name' => 'required|string|max:128',
|
||||
'status' => 'integer|in:0,1',
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'id' => '公司ID',
|
||||
'company_type' => '公司类型',
|
||||
'name' => '公司名称',
|
||||
'status' => '状态',
|
||||
];
|
||||
}
|
||||
}
|
89
app/Request/FirstCompanyRequest.php
Normal file
89
app/Request/FirstCompanyRequest.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/5
|
||||
* Time: 下午9:28
|
||||
* Description:
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request;
|
||||
|
||||
class FirstCompanyRequest extends AbstractRequest
|
||||
{
|
||||
public array $scenes = [
|
||||
'addFirstCompany' => [
|
||||
'domain',
|
||||
'name',
|
||||
'full_name',
|
||||
'company_type',
|
||||
'address',
|
||||
'logo',
|
||||
'owner', // 公司负责人
|
||||
'id_card', // 法人身份证
|
||||
'mobile',
|
||||
'org_code',
|
||||
'remark',
|
||||
'active_status',
|
||||
'activation_date',
|
||||
],
|
||||
];
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'id' => 'integer',
|
||||
'name' => 'required|string|max:60',
|
||||
// 域名只能是英文、数字、下划线、短横线
|
||||
'domain' => 'required|string|max:100|regex:/^[a-zA-Z0-9_-]+$/',
|
||||
'full_name' => 'required|string|max:255',
|
||||
'company_type' => 'required|in:1,2',
|
||||
'address' => 'required|string|max:255',
|
||||
'logo' => 'string|max:255',
|
||||
'owner' => 'required|string|max:45',
|
||||
'id_card' => 'string|max:18',
|
||||
// 验证手机号,加正则验证
|
||||
'mobile' => 'required|string|max:11|regex:/^1[3-9]\d{9}$/',
|
||||
'org_code' => 'string|max:64',
|
||||
'remark' => 'string|max:255',
|
||||
'active_status' => 'required|integer|in:0,1',
|
||||
// 激活日期:不能小于当前时间
|
||||
'activation_date' => 'date|date_format:Y-m-d|after_or_equal:today',
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'id' => '公司ID',
|
||||
'name' => '公司名称',
|
||||
'domain' => '公司域名',
|
||||
'full_name' => '公司全称',
|
||||
'company_type' => '公司类型',
|
||||
'address' => '公司地址',
|
||||
'logo' => '公司logo',
|
||||
'owner' => '公司负责人',
|
||||
'id_card' => '法人身份证',
|
||||
'mobile' => '手机号码',
|
||||
'org_code' => '组织机构代码',
|
||||
'remark' => '备注',
|
||||
'active_status' => '激活状态',
|
||||
'activation_date' => '激活日期',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'domain.regex' => '只能是英文、数字、下划线、短横线',
|
||||
'mobile.regex' => '手机号码格式不正确',
|
||||
'activation_date.after_or_equal' => '激活日期不能小于当前时间',
|
||||
];
|
||||
}
|
||||
}
|
84
app/Request/PurchaseRequest.php
Normal file
84
app/Request/PurchaseRequest.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/3
|
||||
* Time: 下午8:25
|
||||
* Description: 用户验证类。
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request;
|
||||
|
||||
class PurchaseRequest extends AbstractRequest
|
||||
{
|
||||
public array $scenes = [
|
||||
'userLogin' => ['login_name', 'password'],
|
||||
'addUser' => [
|
||||
'login_name', // 登录用户名
|
||||
'password' => 'string|between:6,15', // 密码
|
||||
'dept_id', // 部门ID
|
||||
'department', // 部门名称
|
||||
'emp_id', // 员工工号
|
||||
'name', // 姓名
|
||||
'mobile', // 手机号
|
||||
'email', // 邮箱地址
|
||||
'avatar', // 头像
|
||||
'active_status', // 状态 0禁用 1启用
|
||||
'remark', // 备注
|
||||
'role_ids', // 角色ID列表
|
||||
'role_ids.*' // 角色ID
|
||||
],
|
||||
'getUserList' => [
|
||||
'page', // 页码
|
||||
'pageSize', // 页大小
|
||||
]
|
||||
];
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'login_name' => 'required|string|regex:/^[a-zA-Z0-9_]+$/|between:3,20',
|
||||
'password' => 'required|string|between:6,15',
|
||||
'dept_id' => 'integer|min:1',
|
||||
'department' => 'string|between:2,20',
|
||||
'emp_id' => 'integer|min:1',
|
||||
'name' => 'string|between:2,20',
|
||||
'mobile' => 'string|between:11,11',
|
||||
'email' => 'string|between:6,30',
|
||||
'avatar' => 'string|between:1,255',
|
||||
'active_status' => 'in:0,1',
|
||||
'remark' => 'string|between:1,255',
|
||||
'role_ids' => 'array',
|
||||
'role_ids.*' => 'integer|min:1|distinct',
|
||||
'page' => 'integer|min:1',
|
||||
'pageSize' => 'integer|min:1',
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'login_name' => '登录账号',
|
||||
'password' => '登录密码',
|
||||
'dept_id' => '部门ID',
|
||||
'department' => '部门名称',
|
||||
'emp_id' => '员工工号',
|
||||
'name' => '姓名',
|
||||
'mobile' => '手机号',
|
||||
'email' => '邮箱地址',
|
||||
'avatar' => '头像',
|
||||
'active_status' => '状态',
|
||||
'remark' => '备注',
|
||||
'role_ids' => '角色ID列表',
|
||||
'role_ids.*' => '角色ID',
|
||||
'page' => '页码',
|
||||
'pageSize' => '页大小',
|
||||
];
|
||||
}
|
||||
}
|
48
app/Request/RoleRequest.php
Normal file
48
app/Request/RoleRequest.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/4
|
||||
* Time: 下午2:54
|
||||
* Description:
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request;
|
||||
|
||||
class RoleRequest extends AbstractRequest
|
||||
{
|
||||
public array $scenes = [
|
||||
'addRole' => [
|
||||
'id',
|
||||
'role_name',
|
||||
'active_status',
|
||||
'sort',
|
||||
],
|
||||
];
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'id' => 'integer',
|
||||
'role_name' => 'required|string',
|
||||
'active_status' => 'required|integer',
|
||||
'sort' => 'required|integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'id' => '角色ID',
|
||||
'role_name' => '角色名称',
|
||||
'active_status' => '角色状态',
|
||||
'sort' => '排序',
|
||||
];
|
||||
}
|
||||
}
|
84
app/Request/UserRequest.php
Normal file
84
app/Request/UserRequest.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/3
|
||||
* Time: 下午8:25
|
||||
* Description: 用户验证类。
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request;
|
||||
|
||||
class UserRequest extends AbstractRequest
|
||||
{
|
||||
public array $scenes = [
|
||||
'userLogin' => ['login_name', 'password'],
|
||||
'addUser' => [
|
||||
'login_name', // 登录用户名
|
||||
'password' => 'string|between:6,15', // 密码
|
||||
'dept_id', // 部门ID
|
||||
'department', // 部门名称
|
||||
'emp_id', // 员工工号
|
||||
'name', // 姓名
|
||||
'mobile', // 手机号
|
||||
'email', // 邮箱地址
|
||||
'avatar', // 头像
|
||||
'active_status', // 状态 0禁用 1启用
|
||||
'remark', // 备注
|
||||
'role_ids', // 角色ID列表
|
||||
'role_ids.*' // 角色ID
|
||||
],
|
||||
'getUserList' => [
|
||||
'page', // 页码
|
||||
'pageSize', // 页大小
|
||||
]
|
||||
];
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'login_name' => 'required|string|regex:/^[a-zA-Z0-9_]+$/|between:3,20',
|
||||
'password' => 'required|string|between:6,15',
|
||||
'dept_id' => 'integer|min:1',
|
||||
'department' => 'string|between:2,20',
|
||||
'emp_id' => 'integer|min:1',
|
||||
'name' => 'string|between:2,20',
|
||||
'mobile' => 'string|between:11,11',
|
||||
'email' => 'string|between:6,30',
|
||||
'avatar' => 'string|between:1,255',
|
||||
'active_status' => 'in:0,1',
|
||||
'remark' => 'string|between:1,255',
|
||||
'role_ids' => 'array',
|
||||
'role_ids.*' => 'integer|min:1|distinct',
|
||||
'page' => 'integer|min:1',
|
||||
'pageSize' => 'integer|min:1',
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'login_name' => '登录账号',
|
||||
'password' => '登录密码',
|
||||
'dept_id' => '部门ID',
|
||||
'department' => '部门名称',
|
||||
'emp_id' => '员工工号',
|
||||
'name' => '姓名',
|
||||
'mobile' => '手机号',
|
||||
'email' => '邮箱地址',
|
||||
'avatar' => '头像',
|
||||
'active_status' => '状态',
|
||||
'remark' => '备注',
|
||||
'role_ids' => '角色ID列表',
|
||||
'role_ids.*' => '角色ID',
|
||||
'page' => '页码',
|
||||
'pageSize' => '页大小',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user