feat: 添加新增/更新/设置排序值/删除接口

This commit is contained in:
2025-02-20 14:13:30 +08:00
parent e1697fd66d
commit 13d75dcb2c
6 changed files with 226 additions and 6 deletions

View File

@@ -0,0 +1,94 @@
<?php
declare (strict_types = 1);
namespace app\admin\validate\v1;
use think\Validate;
class VideoValidate 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:125',
'video' => 'max:125',
'link' => 'url|max:125',
'sort' => 'integer',
'recommend' => 'integer|in:1,0',
'status' => 'integer|in:1,-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' => '语言不能为空',
'language_id.integer' => '语言参数类型错误',
'category_id.require' => '分类不能为空',
'category_id.integer' => '分类参数类型错误',
'name.require' => '名称不能为空',
'name.max' => '名称不能超过64个字符',
'desc.max' => '描述不能超过255个字符',
'image.max' => '图片不能超过125个字符',
'video.max' => '视频不能超过125个字符',
'link.url' => '链接格式错误',
'link.max' => '链接不能超过125个字符',
'sort.integer' => '排序参数类型错误',
'recommend.integer' => '推荐参数类型错误',
'recommend.in' => '推荐参数错误必须是1或0',
'status.integer' => '状态参数类型错误',
'status.in' => '状态参数错误必须是1或-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']);
}
/**
* 删除韬晦
*/
public function sceneDelete()
{
return $this->only(['id']);
}
}