init: 项目初始代码
This commit is contained in:
60
app/api/validate/Question.php
Normal file
60
app/api/validate/Question.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 用户反馈类
|
||||
* Class Question
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class Question 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'],
|
||||
'name|姓名' => ['length:1,40','require'],
|
||||
'country_id|国家' => ['length:1,30','require'],
|
||||
'email|邮箱' => ['length:1,60'],
|
||||
'phone|手机号码' => ['length:1,20','regex:/^1[23456789]{1}\d{9}$/'],
|
||||
'order_sn|SKU' => ['length:1,50'],
|
||||
'product_model|产品型号' => ['length:1,128'],
|
||||
'is_done|解决与否' => ['integer','in:0,1'],
|
||||
'os|操作系统' => ['length:1,50'],
|
||||
'image' => [
|
||||
'fileSize' => 1024 * 1024 * 10,
|
||||
'fileExt' => 'xls,xlsx,jpg,png,docx,doc,rar,zip',
|
||||
'fileMime' => 'image/jpeg,image/png,image/gif,application/x-rar-compressed,application/zip,application/pdf,audio/ogg,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [];
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $scene = [
|
||||
'index' => ['page','size','is_done','product_model'],
|
||||
'read' => ['id'],
|
||||
'create' => ['site_id','country_id','name','email','phone','order_sn','product_model','os','desc','sort'],
|
||||
'update' => ['id','country_id','name','email','phone','order_sn','product_model','os','desc','sort'],
|
||||
'del' => ['id'],
|
||||
'isDone' => ['id','is_done'],
|
||||
'upload' => ['image']
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user