feat: 添加问答分页/详情/新增/更新/设置排序值/删除接口
This commit is contained in:
57
app/admin/validate/v1/FaqValidate.php
Normal file
57
app/admin/validate/v1/FaqValidate.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\validate\v1;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class FaqValidate extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'language_id' => 'require|integer',
|
||||
'image' => 'max:125',
|
||||
'question' => 'require|max:255',
|
||||
'recommend' => 'integer|in:0,1',
|
||||
'sort' => 'integer'
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'id.require' => 'ID不能为空',
|
||||
'id.integer' => 'ID必须是整数',
|
||||
'language_id.require' => '语言ID不能为空',
|
||||
'language_id.integer' => '语言ID必须是整数',
|
||||
'language_id.mustOmit' => '语言ID不能修改',
|
||||
'image.max' => '图片不能超过125个字符',
|
||||
'question.require' => '问答标题不能为空',
|
||||
'question.max' => '问答标题不能超过255个字符',
|
||||
'recommend.integer' => '推荐值必须是整数',
|
||||
'recommend.in' => '推荐值只能是0或1',
|
||||
'sort.integer' => '排序值必须是整数'
|
||||
];
|
||||
|
||||
// 新增场景
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', 'require|integer');
|
||||
}
|
||||
|
||||
// 更新场景
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove('language_id', 'require|integer')->append('language_id', 'mustOmit');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user