150 lines
3.6 KiB
PHP
150 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\project;
|
||
|
||
|
||
use app\common\model\dict\DictData;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectLogs;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 项目日志管理验证器
|
||
* Class ProjectLogsValidate
|
||
* @package app\adminapi\validate\project
|
||
*/
|
||
class ProjectLogsValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkLog',
|
||
'project_id' => 'require|checkProject',
|
||
'theme' => 'require',
|
||
'date' => 'require|date',
|
||
'follow_type' => 'require|checkFollowType',
|
||
'next_follow_up_date' => 'date|checkNextFollowUpDate',
|
||
];
|
||
|
||
protected $message = [
|
||
'id.require' => '缺少必要参数',
|
||
'project_id.require' => '请选择项目',
|
||
'theme.require' => '主题不能为空',
|
||
'date.require' => '日期不能为空',
|
||
'date.date' => '日期格式不正确',
|
||
'follow_type.require' => '请选择类型',
|
||
'next_follow_up_date.date' => '下次跟进时间格式不正确',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'project_id' => '项目名称',
|
||
'theme' => '主题',
|
||
'date' => '日期',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return ProjectLogsValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/14 09:17
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id',true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return ProjectLogsValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/14 09:17
|
||
*/
|
||
public function sceneEdit()
|
||
{}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return ProjectLogsValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/14 09:17
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return ProjectLogsValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/14 09:17
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkLog($value): bool|string
|
||
{
|
||
$data = ProjectLogs::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '数据不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkProject($value): bool|string
|
||
{
|
||
$project = Project::where('id',$value)->findOrEmpty();
|
||
if($project->isEmpty()){
|
||
return '项目不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkFollowType($value): bool|string
|
||
{
|
||
$dictDate = DictData::where('type_value','follow_type')->column('value');
|
||
if(!in_array($value,$dictDate)){
|
||
return '类型不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkNextFollowUpDate($value,$rule,$data): bool|string
|
||
{
|
||
$a = strtotime($value);
|
||
$b = strtotime($data['date']);
|
||
if($a < $b){
|
||
return '下次跟进时间不能小于日志日期';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |