150 lines
3.7 KiB
PHP
150 lines
3.7 KiB
PHP
<?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\validate\project;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectMember;
|
||
use app\common\model\project\ProjectRoleSet;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 项目成员验证器
|
||
* Class ProjectMemberValidate
|
||
* @package app\adminapi\validate\project
|
||
*/
|
||
class ProjectMemberValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'project_id' => 'require|checkProject',
|
||
'project_role_id' => 'require|checkProjectRole',
|
||
'admin_id' => 'require|checkAdmin',
|
||
'working_unit_price' => 'require|float|egt:0',
|
||
];
|
||
|
||
protected $message = [
|
||
'id.require' => '缺少必要参数',
|
||
'project_id.require' => '请选择项目',
|
||
'project_role_id.require' => '请选择项目角色',
|
||
'admin_id.require' => '请选择人员',
|
||
'working_unit_price.require' => '请填写工时单价',
|
||
'working_unit_price.float' => '工时单价必须是数字',
|
||
'working_unit_price.egt' => '工时单价必须大于等于0',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'project_id' => '项目id',
|
||
'project_role_id' => '角色名称',
|
||
'admin_id' => '人员id',
|
||
'working_unit_price' => '工时单价',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return ProjectMemberValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/15 09:59
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id',true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return ProjectMemberValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/15 09:59
|
||
*/
|
||
public function sceneEdit()
|
||
{}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return ProjectMemberValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/15 09:59
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return ProjectMemberValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/15 09:59
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = ProjectMember::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '数据不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkProject($value): bool|string
|
||
{
|
||
$data = Project::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '项目不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkProjectRole($value): bool|string
|
||
{
|
||
$data = ProjectRoleSet::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '项目角色不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkAdmin($value): bool|string
|
||
{
|
||
$data = Admin::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '人员不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |