feat: 添加附件(下载管理)分页/详情/新增/更新/设置排序值/删除接口
This commit is contained in:
87
app/admin/validate/v1/AttachmentValidate.php
Normal file
87
app/admin/validate/v1/AttachmentValidate.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\validate\v1;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class AttachmentValidate extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'language_id' => 'require|integer',
|
||||
'category_id' => 'require|integer',
|
||||
'name' => 'require|max:64',
|
||||
'desc' => 'max:255',
|
||||
'image' => 'max:255',
|
||||
'applicable_to' => 'max:255',
|
||||
'support_platform' => 'max:255',
|
||||
'attach.*.filepath' => 'string',
|
||||
'attach.*.ext' => 'string',
|
||||
'attach.*.btn_name' => 'string',
|
||||
'sort' => 'integer',
|
||||
'recommend' => 'in:0,1',
|
||||
'seo_title' => 'max:255',
|
||||
'seo_keywords' => 'max:255',
|
||||
'seo_desc' => 'max:255',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @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必须是整数',
|
||||
'name.require' => '名称不能为空',
|
||||
'name.max' => '名称不能超过64个字符',
|
||||
'desc.max' => '描述不能超过255个字符',
|
||||
'image.max' => '图片不能超过255个字符',
|
||||
'applicable_to.max' => '适用对象不能超过255个字符',
|
||||
'support_platform.max' => '支持平台不能超过255个字符',
|
||||
'attach.*.file_path.string' => '附件路径必须是字符串',
|
||||
'attach.*.file_ext.string' => '附件扩展名必须是字符串',
|
||||
'attach.*.btn_name.string' => '附件按钮名必须是字符串',
|
||||
'sort.integer' => '排序必须是整数',
|
||||
'recommend.in' => '推荐状态必须是0或1',
|
||||
'seo_title.max' => 'SEO标题不能超过255个字符',
|
||||
'seo_keywords.max' => 'SEO关键字不能超过255个字符',
|
||||
'seo_desc.max' => 'SEO描述不能超过255个字符',
|
||||
];
|
||||
|
||||
/**
|
||||
* 新增场景
|
||||
*/
|
||||
public function sceneCreate()
|
||||
{
|
||||
return $this->remove('id', 'require|integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新场景
|
||||
*/
|
||||
public function sceneUpdate()
|
||||
{
|
||||
return $this->remove('language_id', 'require|integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序场景
|
||||
*/
|
||||
public function sceneSort()
|
||||
{
|
||||
return $this->only(['sort']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user