9 changed files with 463 additions and 70 deletions
-
4app/Http/Controllers/Api/ArticleController.php
-
2app/Http/Requests/GoodsRequest.php
-
100app/Http/Requests/PaymentRequest.php
-
105app/Http/Requests/RegionRequest.php
-
94app/Http/Requests/SysconfigRequest.php
-
101app/Http/Requests/TokenRequest.php
-
106app/Http/Requests/VerifyCodeRequest.php
-
6lqycms.sql
-
3routes/web.php
@ -1,22 +1,98 @@ |
|||
<?php |
|||
namespace app\common\validate; |
|||
namespace App\Http\Requests; |
|||
|
|||
use think\Validate; |
|||
|
|||
class Payment extends Validate |
|||
class PaymentRequest extends BaseRequest |
|||
{ |
|||
// 验证规则
|
|||
protected $rule = [ |
|||
['id', 'require|number','ID必填|ID必须是数字'], |
|||
['pay_code', 'require|max:20','支付方式的英文缩写必填|支付方式的英文缩写不能超过20个字符'], |
|||
['pay_name', 'require|max:100','支付方式名称必填|支付方式名称不能超过100个字符'], |
|||
['pay_fee', 'max:10','支付费用不能超过10个字符'], |
|||
['status', 'in:0,1', '是否可用;0否;1是'], |
|||
['listorder', 'number','排序必须是数字'], |
|||
//总的验证规则
|
|||
protected $rules = [ |
|||
'id' => 'required|integer', |
|||
'pay_code' => 'required|max:20', |
|||
'pay_name' => 'required|max:100', |
|||
'pay_fee' => ['required','regex:/^\d{0,10}(\.\d{0,1})?$/'], |
|||
'status' => 'integer|between:[0,1]', |
|||
'listorder' => 'integer|between:[1,9999]', |
|||
]; |
|||
|
|||
//总的自定义错误信息
|
|||
protected $messages = [ |
|||
'id.required' => 'ID必填', |
|||
'id.integer' => 'ID必须为数字', |
|||
'pay_code.required' => '支付方式的英文缩写必填', |
|||
'pay_code.max' => '支付方式的英文缩写不能超过20个字符', |
|||
'pay_name.required' => '支付方式名称必填', |
|||
'pay_name.max' => '支付方式名称不能超过100个字符', |
|||
'pay_fee.required' => '支付费用必填', |
|||
'pay_fee.regex' => '支付费用只能带2位小数的数字', |
|||
'status.integer' => '状态必须是数字', |
|||
'status.between' => '是否可用;0否;1是', |
|||
'listorder.integer' => '排序必须是数字', |
|||
'listorder.between' => '排序只能1-9999', |
|||
]; |
|||
|
|||
//场景验证规则
|
|||
protected $scene = [ |
|||
'add' => ['pay_code', 'pay_name', 'pay_fee', 'status', 'listorder'], |
|||
'edit' => ['pay_code', 'pay_name', 'pay_fee', 'status', 'listorder'], |
|||
'del' => ['id'], |
|||
]; |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return true; //修改为true
|
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return $this->rules; |
|||
} |
|||
|
|||
/** |
|||
* 获取被定义验证规则的错误消息. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function messages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
|
|||
//获取场景验证规则
|
|||
public function getSceneRules($name, $fields = null) |
|||
{ |
|||
$res = array(); |
|||
|
|||
if(!isset($this->scene[$name])) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
$scene = $this->scene[$name]; |
|||
if($fields != null && is_array($fields)) |
|||
{ |
|||
$scene = $fields; |
|||
} |
|||
|
|||
foreach($scene as $k=>$v) |
|||
{ |
|||
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];} |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
//获取场景验证规则自定义错误信息
|
|||
public function getSceneRulesMessages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
} |
@ -1,22 +1,101 @@ |
|||
<?php |
|||
namespace app\common\validate; |
|||
namespace App\Http\Requests; |
|||
|
|||
use think\Validate; |
|||
|
|||
class Region extends Validate |
|||
class RegionRequest extends BaseRequest |
|||
{ |
|||
// 验证规则
|
|||
protected $rule = [ |
|||
['id', 'require|number','ID必填|ID必须是数字'], |
|||
['parent_id', 'number','父级ID必须是数字'], |
|||
['name', 'require|max:64','名称必填|名称不能超过64个字符'], |
|||
['type', 'in:0,1,2,3','层级,0国家,1省,2市,3区'], |
|||
['sort_name', 'max:50','拼音或英文简写不能超过50个字符'], |
|||
['area_code', 'max:10', '电话区号不能超过10个字符'], |
|||
//总的验证规则
|
|||
protected $rules = [ |
|||
'id' => 'required|integer', |
|||
'name' => 'required|max:64', |
|||
'parent_id' => 'integer', |
|||
'type' => 'integer|between:[0,3]', |
|||
'sort_name' => 'max:50', |
|||
'is_oversea' => 'integer|between:[0,1]', |
|||
'area_code' => 'max:10', |
|||
'status' => 'integer|between:[0,1]', |
|||
]; |
|||
|
|||
//总的自定义错误信息
|
|||
protected $messages = [ |
|||
'id.required' => 'ID必填', |
|||
'id.integer' => 'ID必须为数字', |
|||
'name.required' => '名称必填', |
|||
'name.max' => '名称不能超过60个字符', |
|||
'parent_id.integer' => '父级id必须为数字', |
|||
'type.integer' => '层级必须是数字', |
|||
'type.between' => '层级,0国家,1省,2市,3区', |
|||
'sort_name.max' => '拼音或英文简写不能超过50个字符', |
|||
'is_oversea.integer' => '类型必须是数字', |
|||
'is_oversea.between' => '0国内地址,1国外地址', |
|||
'area_code.max' => '电话区号不能超过10个字符', |
|||
'status.integer' => '状态必须是数字', |
|||
'status.between' => '状态 0隐藏 1显示', |
|||
]; |
|||
|
|||
//场景验证规则
|
|||
protected $scene = [ |
|||
'add' => ['name', 'parent_id', 'type', 'sort_name', 'area_code'], |
|||
'add' => ['name', 'parent_id', 'type', 'sort_name', 'is_oversea', 'area_code', 'status'], |
|||
'edit' => ['name', 'parent_id', 'type', 'sort_name', 'is_oversea', 'area_code', 'status'], |
|||
'del' => ['id'], |
|||
]; |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return true; //修改为true
|
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return $this->rules; |
|||
} |
|||
|
|||
/** |
|||
* 获取被定义验证规则的错误消息. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function messages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
|
|||
//获取场景验证规则
|
|||
public function getSceneRules($name, $fields = null) |
|||
{ |
|||
$res = array(); |
|||
|
|||
if(!isset($this->scene[$name])) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
$scene = $this->scene[$name]; |
|||
if($fields != null && is_array($fields)) |
|||
{ |
|||
$scene = $fields; |
|||
} |
|||
|
|||
foreach($scene as $k=>$v) |
|||
{ |
|||
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];} |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
//获取场景验证规则自定义错误信息
|
|||
public function getSceneRulesMessages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
} |
@ -1,20 +1,92 @@ |
|||
<?php |
|||
namespace app\common\validate; |
|||
namespace App\Http\Requests; |
|||
|
|||
use think\Validate; |
|||
|
|||
class Sysconfig extends Validate |
|||
class SysconfigRequest extends BaseRequest |
|||
{ |
|||
// 验证规则
|
|||
protected $rule = [ |
|||
['id', 'require|number','ID必填|ID必须是数字'], |
|||
['varname', 'require|max:100','变量名必填|变量名不能超过100个字符'], |
|||
['info', 'require|max:100','变量值必填|变量值不能超过100个字符'], |
|||
['value', 'require', '变量说明必填'], |
|||
//总的验证规则
|
|||
protected $rules = [ |
|||
'id' => 'required|integer', |
|||
'varname' => 'required|max:100', |
|||
'info' => 'required|max:100', |
|||
'is_show' => 'integer|between:[0,5]', |
|||
]; |
|||
|
|||
//总的自定义错误信息
|
|||
protected $messages = [ |
|||
'id.required' => 'ID必填', |
|||
'id.integer' => 'ID必须为数字', |
|||
'varname.required' => '变量名必填', |
|||
'varname.max' => '变量名不能超过100个字符', |
|||
'info.required' => '变量值必填', |
|||
'info.max' => '变量值不能超过100个字符', |
|||
'is_show.integer' => '状态必须是数字', |
|||
'is_show.between' => '是否显示,默认0显示', |
|||
]; |
|||
|
|||
//场景验证规则
|
|||
protected $scene = [ |
|||
'add' => ['varname', 'info', 'value'], |
|||
'add' => ['varname', 'info', 'is_show'], |
|||
'edit' => ['varname', 'info', 'is_show'], |
|||
'del' => ['id'], |
|||
]; |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return true; //修改为true
|
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return $this->rules; |
|||
} |
|||
|
|||
/** |
|||
* 获取被定义验证规则的错误消息. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function messages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
|
|||
//获取场景验证规则
|
|||
public function getSceneRules($name, $fields = null) |
|||
{ |
|||
$res = array(); |
|||
|
|||
if(!isset($this->scene[$name])) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
$scene = $this->scene[$name]; |
|||
if($fields != null && is_array($fields)) |
|||
{ |
|||
$scene = $fields; |
|||
} |
|||
|
|||
foreach($scene as $k=>$v) |
|||
{ |
|||
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];} |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
//获取场景验证规则自定义错误信息
|
|||
public function getSceneRulesMessages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
} |
@ -1,20 +1,99 @@ |
|||
<?php |
|||
namespace app\common\validate; |
|||
namespace App\Http\Requests; |
|||
|
|||
use think\Validate; |
|||
|
|||
class Token extends Validate |
|||
class TokenRequest extends BaseRequest |
|||
{ |
|||
// 验证规则
|
|||
protected $rule = [ |
|||
['id', 'require|number','ID必填|ID必须是数字'], |
|||
['token', 'require|max:128','token必填|token不能超过128个字符'], |
|||
['type', 'in:0,1,2,3,4,5,6','token类型,0:app, 1:admin, 2:weixin, 3:wap, 4: pc'], |
|||
['uid', 'require|number','uid必填|uid必须是数字'], |
|||
//总的验证规则
|
|||
protected $rules = [ |
|||
'id' => 'required|integer', |
|||
'token' => 'required|max:128', |
|||
'type' => 'required|integer|between:[0,6]', |
|||
'uid' => 'required|integer', |
|||
'created_at' => 'required|date_format:"Y-m-d H:i:s"', |
|||
'expired_at' => 'required|date_format:"Y-m-d H:i:s"', |
|||
]; |
|||
|
|||
//总的自定义错误信息
|
|||
protected $messages = [ |
|||
'id.required' => 'ID必填', |
|||
'id.integer' => 'ID必须为数字', |
|||
'token.required' => 'token必填', |
|||
'token.max' => 'token不能超过128个字符', |
|||
'type.required' => 'token类型必填', |
|||
'type.integer' => 'token类型必须是数字', |
|||
'type.between' => '0:app, 1:admin, 2:weixin, 3:wap, 4: pc', |
|||
'uid.required' => 'UID必填', |
|||
'uid.integer' => 'UID必须为数字', |
|||
'created_at.required' => '添加时间必填', |
|||
'created_at.regex' => '添加时间格式不正确,Y-m-d H:i:s', |
|||
'expired_at.required' => '过期时间必填', |
|||
'expired_at.regex' => '过期时间格式不正确,Y-m-d H:i:s', |
|||
]; |
|||
|
|||
//场景验证规则
|
|||
protected $scene = [ |
|||
'add' => ['token', 'type', 'uid'], |
|||
'add' => ['token', 'type', 'uid', 'created_at', 'expired_at'], |
|||
'edit' => ['token', 'type', 'uid', 'created_at', 'expired_at'], |
|||
'del' => ['id'], |
|||
]; |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return true; //修改为true
|
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return $this->rules; |
|||
} |
|||
|
|||
/** |
|||
* 获取被定义验证规则的错误消息. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function messages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
|
|||
//获取场景验证规则
|
|||
public function getSceneRules($name, $fields = null) |
|||
{ |
|||
$res = array(); |
|||
|
|||
if(!isset($this->scene[$name])) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
$scene = $this->scene[$name]; |
|||
if($fields != null && is_array($fields)) |
|||
{ |
|||
$scene = $fields; |
|||
} |
|||
|
|||
foreach($scene as $k=>$v) |
|||
{ |
|||
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];} |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
//获取场景验证规则自定义错误信息
|
|||
public function getSceneRulesMessages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
} |
@ -1,22 +1,102 @@ |
|||
<?php |
|||
namespace app\common\validate; |
|||
namespace App\Http\Requests; |
|||
|
|||
use think\Validate; |
|||
|
|||
class VerifyCode extends Validate |
|||
class VerifyCodeRequest extends BaseRequest |
|||
{ |
|||
// 验证规则
|
|||
protected $rule = [ |
|||
['id', 'require|number','ID必填|ID必须是数字'], |
|||
['code', 'require|max:10','验证码必填|验证码不能超过10个字符'], |
|||
['type', 'in:0,1,2,3,4,5,6,7,8,9','0通用,注册,1:手机绑定业务验证码,2:密码修改业务验证码'], |
|||
['mobile', 'require|max:20','手机号必填|手机号不能超过20个字符'], |
|||
['status', 'in:0,1','0:未使用 1:已使用'], |
|||
['result', 'max:500', '返回结果不能超过500个字符'], |
|||
//总的验证规则
|
|||
protected $rules = [ |
|||
'id' => 'required|integer', |
|||
'code' => 'required|max:10', |
|||
'type' => 'required|integer|between:[0,6]', |
|||
'mobile' => 'required|max:20', |
|||
'status' => 'integer|between:[0,1]', |
|||
'created_at' => 'required|date_format:"Y-m-d H:i:s"', |
|||
'expired_at' => 'required|date_format:"Y-m-d H:i:s"', |
|||
]; |
|||
|
|||
//总的自定义错误信息
|
|||
protected $messages = [ |
|||
'id.required' => 'ID必填', |
|||
'id.integer' => 'ID必须为数字', |
|||
'code.required' => '验证码必填', |
|||
'code.max' => '验证码不能超过10个字符', |
|||
'type.required' => '验证码类型必填', |
|||
'type.integer' => '验证码类型必须是数字', |
|||
'type.between' => '0通用,注册,1:手机绑定业务验证码,2:密码修改业务验证码', |
|||
'mobile.required' => '手机号必填', |
|||
'mobile.max' => '手机号不能超过20个字符', |
|||
'status.integer' => '状态必须是数字', |
|||
'status.between' => '0:未使用 1:已使用', |
|||
'created_at.required' => '添加时间必填', |
|||
'created_at.regex' => '添加时间格式不正确,Y-m-d H:i:s', |
|||
'expired_at.required' => '过期时间必填', |
|||
'expired_at.regex' => '过期时间格式不正确,Y-m-d H:i:s', |
|||
]; |
|||
|
|||
//场景验证规则
|
|||
protected $scene = [ |
|||
'add' => ['mobile', 'text', 'status', 'result'], |
|||
'add' => ['code', 'type', 'mobile', 'status', 'created_at', 'expired_at'], |
|||
'edit' => ['code', 'type', 'mobile', 'status', 'created_at', 'expired_at'], |
|||
'del' => ['id'], |
|||
]; |
|||
|
|||
/** |
|||
* Determine if the user is authorized to make this request. |
|||
* |
|||
* @return bool |
|||
*/ |
|||
public function authorize() |
|||
{ |
|||
return true; //修改为true
|
|||
} |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return $this->rules; |
|||
} |
|||
|
|||
/** |
|||
* 获取被定义验证规则的错误消息. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function messages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
|
|||
//获取场景验证规则
|
|||
public function getSceneRules($name, $fields = null) |
|||
{ |
|||
$res = array(); |
|||
|
|||
if(!isset($this->scene[$name])) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
$scene = $this->scene[$name]; |
|||
if($fields != null && is_array($fields)) |
|||
{ |
|||
$scene = $fields; |
|||
} |
|||
|
|||
foreach($scene as $k=>$v) |
|||
{ |
|||
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];} |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
//获取场景验证规则自定义错误信息
|
|||
public function getSceneRulesMessages() |
|||
{ |
|||
return $this->messages; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue