engineering/app/adminapi/validate/supervision_work/SupervisionProblemValidate.php
2024-02-28 11:19:11 +08:00

154 lines
4.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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\supervision_work;
use app\common\model\dict\DictData;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\validate\BaseValidate;
/**
* 问题跟踪台账验证器
* Class SupervisionProblemValidate
* @package app\adminapi\validate\supervision_work
*/
class SupervisionProblemValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'data_id' => 'require',
'data_type' => 'require|in:1,2,3,4,5,6,7',
'problem_cate' => 'require|checkProblemCate',
'problem_description' => 'require',
'problem_name' => 'require',
'rectification_time' => 'require|dateFormat:Y-m-d',
'rectification_user' => 'require',
'rectification_result' => 'require|in:0,1',
'rectification_opinion' => 'require',
'is_rectification' => 'require|in:0,1',
'rectification_annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'data_id' => '数据id',
'data_type' => '数据类型',
'problem_cate' => '问题分类',
'problem_description' => '问题说明',
'problem_name' => '问题名称',
'rectification_time' => '整改时间',
'rectification_user' => '整改人',
'rectification_result' => '整改结果',
'rectification_opinion' => '整改意见',
'is_rectification' => '是否整改',
];
/**
* @notes 添加场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneAdd()
{
return $this->only(['data_id','data_type','problem_cate','problem_description','problem_name']);
}
/**
* @notes 编辑场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneEdit()
{
return $this->only(['id','data_id','data_type','problem_cate','problem_description','problem_name']);
}
/**
* @notes 检查验收场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneCheck()
{
return $this->only(['id','rectification_time','rectification_user','rectification_result','rectification_opinion','rectification_annex']);
}
/**
* @notes 删除场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionProblem::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkProblemCate($value): bool|string
{
$dict = DictData::where('type_value','problem_cate')->column('value');
if(!in_array($value,$dict)){
return '问题分类数据值无效';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
}