131 lines
3.6 KiB
PHP
131 lines
3.6 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\marketing;
|
||
|
||
|
||
use app\common\model\dict\DictData;
|
||
use app\common\model\marketing\MarketingProjectFiling;
|
||
use app\common\model\marketing\MarketingProjectFilingDetail;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 市场经营--项目备案明细验证器
|
||
* Class MarketingProjectFilingDetailValidate
|
||
* @package app\adminapi\validate\marketing
|
||
*/
|
||
class MarketingProjectFilingDetailValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'project_filing_id' => 'require|checkProjectFiling',
|
||
'filing_user' => 'require',
|
||
'filing_role' => 'require|checkFilingRole',
|
||
'reg_time' => 'require|dateFormat:Y-m-d',
|
||
'status' => 'require|checkStatus',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'project_filing_id' => '项目备案id',
|
||
'filing_user' => '备案人员',
|
||
'filing_role' => '备案角色',
|
||
'reg_time' => '登记时间',
|
||
'status' => '状态',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return MarketingProjectFilingDetailValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/05 10:36
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->only(['project_filing_id', 'filing_user', 'filing_role', 'reg_time', 'status']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return MarketingProjectFilingDetailValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/05 10:36
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->only(['id', 'project_filing_id', 'filing_user', 'filing_role', 'reg_time', 'status']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return MarketingProjectFilingDetailValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/05 10:36
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id'])->remove('id', 'checkData');
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return MarketingProjectFilingDetailValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/05 10:36
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = MarketingProjectFilingDetail::where('id', $value)->findOrEmpty();
|
||
return $data->isEmpty() ? '数据不存在' : true;
|
||
}
|
||
|
||
public function checkProjectFiling($value): bool|string
|
||
{
|
||
$data = MarketingProjectFiling::where('id', $value)->findOrEmpty();
|
||
return $data->isEmpty() ? '项目备案数据不存在' : true;
|
||
}
|
||
|
||
public function checkFilingRole($value): bool|string
|
||
{
|
||
$dict = DictData::where('type_value', 'filing_role')->column('value');
|
||
return !in_array($value, $dict) ? '备案角色数据值无效' : true;
|
||
}
|
||
|
||
public function checkStatus($value): bool|string
|
||
{
|
||
$dict = DictData::where('type_value', 'filing_status')->column('value');
|
||
return !in_array($value, $dict) ? '状态数据值无效' : true;
|
||
}
|
||
|
||
} |