feat: 产品分类推荐数据管理
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s
This commit is contained in:
63
app/admin/validate/v1/ProductCategoryRecommendValidate.php
Normal file
63
app/admin/validate/v1/ProductCategoryRecommendValidate.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\validate\v1;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ProductCategoryRecommendValidate extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'language_id' => 'require|integer',
|
||||
'category_id' => 'require|integer',
|
||||
'title' => 'require|max:255',
|
||||
'image' => 'require|max:255',
|
||||
'desc' => 'require|max:255',
|
||||
'link' => 'max:500',
|
||||
'sort' => 'require|integer',
|
||||
'disabled' => 'in:0,1'
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'id.require' => 'ID不能为空',
|
||||
'id.integer' => 'ID必须是整数',
|
||||
'language_id.require' => '语言ID不能为空',
|
||||
'language_id.integer' => '语言ID必须是整数',
|
||||
'category_id.require' => '分类ID不能为空',
|
||||
'category_id.integer' => '分类ID必须是整数',
|
||||
'title.require' => '标题不能为空',
|
||||
'title.max' => '标题长度不能超过:rule个字符',
|
||||
'image.require' => '图片不能为空',
|
||||
'image.max' => '图片长度不能超过:rule个字符',
|
||||
'desc.require' => '描述不能为空',
|
||||
'desc.max' => '描述长度不能超过:rule个字符',
|
||||
'link.max' => '链接长度不能超过:rule个字符',
|
||||
'sort.require' => '排序不能为空',
|
||||
'sort.integer' => '排序必须是整数',
|
||||
'disabled.in' => '禁用状态只能是0或1',
|
||||
];
|
||||
|
||||
// 新增场景
|
||||
protected function sceneCreate()
|
||||
{
|
||||
return $this->remove('id', 'require|integer');
|
||||
}
|
||||
|
||||
// 更新场景
|
||||
protected function sceneUpdate()
|
||||
{
|
||||
return $this->append('id', 'require|integer');
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ namespace app\admin\validate\v1;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
use function PHPSTORM_META\type;
|
||||
|
||||
class ProductValidate extends Validate
|
||||
{
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user