126 lines
3.2 KiB
PHP
126 lines
3.2 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\MarketingCompetitor;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 市场经营--投标管理--竞争对手验证器
|
||
* Class MarketingCompetitorValidate
|
||
* @package app\adminapi\validate\marketing
|
||
*/
|
||
class MarketingCompetitorValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'company_name' => 'require',
|
||
'company_type' => 'require|checkCompanyType',
|
||
'creation_date' => 'dateFormat:Y-m-d',
|
||
'employee_num' => 'integer|egt:0',
|
||
'website' => 'url',
|
||
'annex' => 'checkAnnex',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'company_name' => '单位名称',
|
||
'company_type' => '企业类型',
|
||
'legal_representative' => '法人代表',
|
||
'creation_date' => '成立日期',
|
||
'employee_num' => '员工人数',
|
||
'telephone' => '联系电话',
|
||
'address' => '单位地址',
|
||
'website' => '企业网址',
|
||
'qualifications' => '企业资质',
|
||
'business_scope' => '经营范围',
|
||
'competitive_edge' => '竞争优势',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return MarketingCompetitorValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/12 15:26
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id', true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return MarketingCompetitorValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/12 15:26
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return MarketingCompetitorValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/12 15:26
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id'])->remove('id', 'checkData');
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return MarketingCompetitorValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/12 15:26
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = MarketingCompetitor::where('id', $value)->findOrEmpty();
|
||
return $data->isEmpty() ? '数据不存在' : true;
|
||
}
|
||
|
||
public function checkCompanyType($value): bool|string
|
||
{
|
||
$dict = DictData::where('type_value', 'company_type')->column('value');
|
||
if (!in_array($value, $dict)) {
|
||
return '企业类型数据值无效';
|
||
}
|
||
return true;
|
||
}
|
||
} |