init: 项目初始代码
This commit is contained in:
45
app/api/validate/Faq.php
Normal file
45
app/api/validate/Faq.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* Class Faq
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class Faq 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'],
|
||||
'faq_type_id|问题分类' => ['integer','gt:0'],
|
||||
'question|回答问题' => ['length:1,150','require','unique:faq,question^site_id^platform_id'],
|
||||
'answer|回答内容' => ['length:1,3000'],
|
||||
'sort|排序' => ['between:1,255'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [];
|
||||
|
||||
|
||||
protected $scene = [
|
||||
'index' => ['page','size','answer'],
|
||||
'read' => ['id'],
|
||||
'create' => ['site_id','faq_type_id','question','answer','sort'],
|
||||
'update' => ['id','faq_type_id','question','answer','sort'],
|
||||
'del' => ['id'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user