init: 项目初始代码
This commit is contained in:
53
app/api/validate/Navigator.php
Normal file
53
app/api/validate/Navigator.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 导航栏验证器
|
||||
* Class Navigator
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class Navigator extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => ['require','integer','gt:0'],
|
||||
'page' => ['integer','gt:0'],
|
||||
'size' => ['integer','gt:0'],
|
||||
'site_id|所属站点'=> ['integer','gt:0'],
|
||||
'sort|排序' => ['require','between:1,255'],
|
||||
'name|栏目名称' => ['length:1,128','require','unique:navigator,name^site_id^platform_id'],
|
||||
'is_top|顶部导航' => ['in:0,1','integer'],
|
||||
'is_foot|底部导航' => ['in:0,1','integer'],
|
||||
'pid|上级栏目' => ['require','integer','egt:0'],
|
||||
'icon|图标' => ['length:1,128'],
|
||||
'desc|描述' => ['length:1,128'],
|
||||
'url|文件路径' => ['length:1,128'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [];
|
||||
|
||||
protected $scene = [
|
||||
'tree' => [''],
|
||||
'read' => ['id'],
|
||||
'create' => ['site_id','name','desc','pid','icon','url','sort','is_top','is_foot'],
|
||||
'update' => ['id','name','desc','pid','icon','url','sort','is_top','is_foot'],
|
||||
'del' => ['id'],
|
||||
'sort' => ['id','sort'],
|
||||
'changeStatus' => ['id','is_top','is_foot'],
|
||||
'topTree' => [''],
|
||||
'upload' => ['']
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user