146 lines
3.8 KiB
PHP
146 lines
3.8 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\consult_strategy;
|
||
|
||
|
||
use app\common\model\consult_basic\ConsultProject;
|
||
use app\common\model\consult_catalog\ConsultDirectory;
|
||
use app\common\model\consult_catalog\ConsultSubdirectory;
|
||
use app\common\model\consult_strategy\ConsultContract;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 项目咨询--合同管理验证器
|
||
* Class ConsultContractValidate
|
||
* @package app\adminapi\validate\consult_strategy
|
||
*/
|
||
class ConsultContractValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'project_id' => 'require|checkProject',
|
||
'title' => 'require',
|
||
'directory_id' => 'require|checkDirectory',
|
||
'subdirectory_id' => 'require|checkSubdirectory',
|
||
'remark' => 'require',
|
||
'annex' => 'checkAnnex'
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'project_id' => '项目id',
|
||
'title' => '文档名称',
|
||
'directory_id' => '目录id',
|
||
'subdirectory_id' => '子目录',
|
||
'remark' => '备注',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return ConsultContractValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/11 15:26
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->only(['project_id','title','directory_id','subdirectory_id','remark','annex']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return ConsultContractValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/11 15:26
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->only(['id','project_id','title','directory_id','subdirectory_id','remark','annex']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return ConsultContractValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/11 15:26
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id'])->remove('id','checkData');
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return ConsultContractValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/11 15:26
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = ConsultContract::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '数据不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkProject($value): bool|string
|
||
{
|
||
$data = ConsultProject::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '项目信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkDirectory($value): bool|string
|
||
{
|
||
$data = ConsultDirectory::where('id',$value)->where('menu',7)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '目录信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkSubdirectory($value,$rule,$params): bool|string
|
||
{
|
||
$data = ConsultSubdirectory::where('id',$value)->where('directory_id',$params['directory_id'])->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '子目录信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
} |