161 lines
4.0 KiB
PHP
161 lines
4.0 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\dict\DictData;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectStakeholder;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 项目干系人验证器
|
||
* Class ProjectStakeholderValidate
|
||
* @package app\adminapi\validate\project
|
||
*/
|
||
class ProjectStakeholderValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'project_id' => 'require|checkProject',
|
||
'name' => 'require',
|
||
'identity' => 'require|checkIdentity',
|
||
'phone' => 'require|mobile',
|
||
'email' => 'email',
|
||
'attitude' => 'checkAttitude',
|
||
'degree_adaptability' => 'checkDegree'
|
||
];
|
||
|
||
protected $message = [
|
||
'id.require' => '缺少必要参数',
|
||
'project_id.require' => '请选择项目',
|
||
'name.require' => '请填写姓名',
|
||
'identity.require' => '请选择身份',
|
||
'phone.require' => '请填写电话',
|
||
'phone.mobile' => '电话格式错误',
|
||
'email.email' => '邮箱格式错误',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'project_id' => '项目id',
|
||
'name' => '姓名',
|
||
'identity' => '身份',
|
||
'phone' => '电话',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return ProjectStakeholderValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/15 11:20
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id',true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return ProjectStakeholderValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/15 11:20
|
||
*/
|
||
public function sceneEdit()
|
||
{}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return ProjectStakeholderValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/15 11:20
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return ProjectStakeholderValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/15 11:20
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = ProjectStakeholder::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 checkIdentity($value): bool|string
|
||
{
|
||
$data = DictData::where('type_value','project_stakeholder_identity')->column('value');
|
||
if(!in_array($value,$data)){
|
||
return '身份数据值错误';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkAttitude($value): bool|string
|
||
{
|
||
$data = DictData::where('type_value','project_stakeholder_attitude')->column('value');
|
||
if(!in_array($value,$data)){
|
||
return '对我方态度选项数据值错误';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkDegree($value): bool|string
|
||
{
|
||
$data = DictData::where('type_value','project_stakeholder_degree_adaptability')->column('value');
|
||
if(!in_array($value,$data)){
|
||
return '工作配合度选项数据值错误';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |