Browse Source

字段验证

master
ZLW-PC\Administrator 6 years ago
parent
commit
8965365aea
  1. 65
      app/Http/Controllers/Api/ArctypeController.php
  2. 8
      app/Http/Controllers/Api/ArticleController.php
  3. 4
      app/Http/Logic/ArctypeLogic.php
  4. 4
      app/Http/Logic/ArticleLogic.php
  5. 107
      app/Http/Requests/AdminRequest.php
  6. 96
      app/Http/Requests/AdminRoleRequest.php
  7. 110
      app/Http/Requests/BonusRequest.php
  8. 101
      app/Http/Requests/CartRequest.php
  9. 95
      app/Http/Requests/CollectGoodsRequest.php
  10. 110
      app/Http/Requests/CommentRequest.php
  11. 100
      app/Http/Requests/FeedbackRequest.php
  12. 100
      app/Http/Requests/FriendlinkRequest.php
  13. 121
      app/Http/Requests/GoodsBrandRequest.php
  14. 97
      app/Http/Requests/GoodsImgRequest.php
  15. 20
      app/Http/Requests/GoodsRequest.php
  16. 97
      app/Http/Requests/GoodsSearchwordRequest.php
  17. 130
      app/Http/Requests/GoodsTypeRequest.php
  18. 109
      app/Http/Requests/GuestbookRequest.php
  19. 89
      app/Http/Requests/KeywordRequest.php
  20. 105
      app/Http/Requests/KuaidiRequest.php
  21. 105
      app/Http/Requests/MenuRequest.php
  22. 155
      app/Http/Requests/OrderRequest.php
  23. 117
      app/Http/Requests/PageRequest.php
  24. 58
      lqycms.sql

65
app/Http/Controllers/Api/ArctypeController.php

@ -5,8 +5,9 @@ use App\Http\Controllers\Api\CommonController;
use Illuminate\Http\Request;
use Log;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Http\Model\Arctype;
use App\Http\Logic\ArctypeLogic;
class ArctypeController extends CommonController
{
@ -15,16 +16,21 @@ class ArctypeController extends CommonController
parent::__construct();
}
public function getLogic()
{
return new ArctypeLogic();
}
public function arctypeList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if($request->input('pid', null) !== null){$data['pid'] = $request->input('pid');}
$data['is_show'] = Arctype::IS_SHOW;
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
if($request->input('pid', null) !== null){$where['pid'] = $request->input('pid');}
$where['is_show'] = Arctype::IS_SHOW;
$res = Arctype::getList($data);
if($res == false)
$res = $this->getLogic()->getList($where, array('listorder', 'asc'), '*', $offset, $limit);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
@ -41,11 +47,11 @@ class ArctypeController extends CommonController
public function arctypeDetail(Request $request)
{
//参数
$data['id'] = $request->input('id','');
$data['is_show'] = Arctype::IS_SHOW;
if($data['id']==''){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$where['id'] = $request->input('id',null);
$where['is_show'] = Arctype::IS_SHOW;
if($where['id'] == null){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$res = Arctype::getOne($data);
$res = $this->getLogic()->getOne($where);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
@ -55,4 +61,41 @@ class ArctypeController extends CommonController
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function arctypeAdd(Request $request)
{
if(Helper::isPostRequest())
{
return $this->getLogic()->add($_POST);
}
}
//修改
public function arctypeUpdate(Request $request)
{
if($request->input('id',null)!=null){$id = $request->input('id');}else{$id='';}if(preg_match('/[0-9]*/',$id)){}else{return ReturnData::create(ReturnData::PARAMS_ERROR);}
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function arctypeDelete(Request $request)
{
if($request->input('id',null)!=null){$id = $request->input('id');}else{$id='';}if(preg_match('/[0-9]*/',$id)){}else{return ReturnData::create(ReturnData::PARAMS_ERROR);}
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
return $this->getLogic()->del($where);
}
}
}

8
app/Http/Controllers/Api/ArticleController.php

@ -46,11 +46,11 @@ class ArticleController extends CommonController
public function articleDetail(Request $request)
{
//参数
$data['id'] = $request->input('id');
$data['ischeck'] = Article::IS_CHECK;
if($data['id']==''){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$where['id'] = $request->input('id',null);
$where['ischeck'] = Article::IS_CHECK;
if($where['id']==null){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$res = $this->getLogic()->getOne($data);
$res = $this->getLogic()->getOne($where);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);

4
app/Http/Logic/ArctypeLogic.php

@ -36,6 +36,10 @@ class ArctypeLogic extends BaseLogic
$res['list'][$k] = $this->getDataView($v);
}
}
else
{
return false;
}
return $res;
}

4
app/Http/Logic/ArticleLogic.php

@ -37,6 +37,10 @@ class ArticleLogic extends BaseLogic
$res['list'][$k]->typename = Article::getTypenameAttr(array('typeid' => $v->typeid));
}
}
else
{
return false;
}
return $res;
}

107
app/Http/Requests/AdminRequest.php

@ -0,0 +1,107 @@
<?php
namespace App\Http\Requests;
class AdminRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'username' => 'required|max:30',
'email' => 'required|max:30',
'logintime' => 'integer',
'pwd' => 'required|max:32',
'role_id' => 'required|integer',
'status' => 'integer|between:[0,3]',
'mobile' => 'max:20',
'avatar' => 'max:150',
'create_at' => 'required|integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'username.required' => '用户名必填',
'username.max' => '用户名不能超过30个字符',
'email.required' => '邮箱必填',
'email.max' => '邮箱不能超过30个字符',
'logintime.integer' => '登录时间必须是数字',
'pwd.required' => '密码必填',
'pwd.max' => '密码不能超过32个字符',
'role_id.required' => '角色ID必填',
'role_id.integer' => '角色ID必须为数字',
'status.integer' => '用户状态必须是数字',
'status.between' => '用户状态 0:正常; 1:禁用 ;2:未验证',
'mobile.max' => '手机号不能超过20个字符',
'avatar.max' => '头像不能超过150个字符',
'create_at.required' => '添加时间必填',
'create_at.integer' => '添加时间必须是数字',
];
//场景验证规则
protected $scene = [
'add' => ['username', 'email', 'logintime', 'pwd', 'role_id', 'status', 'mobile', 'avatar', 'create_at'],
'edit' => ['username', 'email', 'logintime', 'pwd', 'role_id', 'status', 'mobile', 'avatar', 'create_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;
}
}

96
app/Http/Requests/AdminRoleRequest.php

@ -0,0 +1,96 @@
<?php
namespace App\Http\Requests;
class AdminRoleRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'name' => 'required|max:30',
'des' => 'max:150',
'status' => 'integer|between:[0,2]',
'pid' => 'integer',
'listorder' => 'integer|between:[1,9999]',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'name.required' => '角色名必填',
'name.max' => '角色名不能大于30个字',
'des.max' => '描述不能大于150个字',
'status.integer' => '状态必须是数字',
'status.between' => '状态,0启用,1禁用',
'pid.integer' => '父级ID必须为数字',
'listorder.integer' => '排序必须是数字',
'listorder.between' => '排序只能1-9999',
];
//场景验证规则
protected $scene = [
'add' => ['name', 'des', 'status', 'pid', 'listorder'],
'edit' => ['name', 'des', 'status', 'pid', '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;
}
}

110
app/Http/Requests/BonusRequest.php

@ -0,0 +1,110 @@
<?php
namespace App\Http\Requests;
class BonusRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'name' => 'required|max:60',
'money' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'min_amount' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'start_time' => 'required|date_format:"Y-m-d H:i:s"',
'end_time' => 'required|date_format:"Y-m-d H:i:s"',
'point' => 'integer|between:[1,9999]',
'status' => 'integer|between:[0,1]',
'add_time' => 'required|integer',
'num' => 'integer|between:[-1,999999]',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'name.required' => '名称必填',
'name.max' => '名称不能大于60个字',
'money.required' => '金额必填',
'money.regex' => '金额只能带2位小数的数字',
'min_amount.required' => '满多少使用必填',
'min_amount.regex' => '满多少使用只能带2位小数的数字',
'start_time.required' => '开始时间必填',
'start_time.date_format' => '开始时间格式不正确,格式:1990-01-01 00:00:00',
'end_time.required' => '结束时间必填',
'end_time.date_format' => '结束时间格式不正确,格式:1990-01-01 00:00:00',
'point.integer' => '兑换优惠券所需积分必须是数字',
'point.between' => '兑换优惠券所需积分只能1-9999',
'status.integer' => '兑换优惠券所需积分必须是数字',
'status.between' => '状态:0可用,1不可用',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须是数字',
'num.integer' => '优惠券数量必须是数字',
'num.between' => '优惠券数量只能-1-999999',
];
//场景验证规则
protected $scene = [
'add' => ['name', 'money', 'min_amount', 'start_time', 'end_time', 'point', 'status', 'add_time', 'num'],
'edit' => ['name', 'money', 'min_amount', 'start_time', 'end_time', 'point', 'status', 'add_time', 'num'],
'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;
}
}

101
app/Http/Requests/CartRequest.php

@ -0,0 +1,101 @@
<?php
namespace App\Http\Requests;
class CartRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'user_id' => 'required|integer',
'goods_id' => 'required|integer',
'shop_id' => 'integer',
'goods_number' => 'required|integer|between:[1,9999]',
'type' => 'integer|between:[0,3]',
'add_time' => 'required|integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'goods_id.required' => '商品ID必填',
'goods_id.integer' => '商品ID必须为数字',
'shop_id.integer' => '商店ID必须为数字',
'goods_number.required' => '商品数量必填',
'goods_number.integer' => '商品数量必须为数字',
'goods_number.between' => '商品数量只能1-9999',
'type.integer' => '购物车商品类型必须为数字',
'type.between' => '购物车商品类型只能0-3',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须是数字',
];
//场景验证规则
protected $scene = [
'add' => ['user_id', 'goods_id', 'shop_id', 'goods_number', 'type', 'add_time'],
'edit' => ['user_id', 'goods_id', 'shop_id', 'goods_number', 'type', 'add_time'],
'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;
}
}

95
app/Http/Requests/CollectGoodsRequest.php

@ -0,0 +1,95 @@
<?php
namespace App\Http\Requests;
class CollectGoodsRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'user_id' => 'required|integer',
'goods_id' => 'required|integer',
'add_time' => 'required|integer',
'is_attention' => 'integer|between:[0,1]',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'goods_id.required' => '商品ID必填',
'goods_id.integer' => '商品ID必须为数字',
'add_time.required' => '收藏时间必填',
'add_time.integer' => '收藏时间必须是数字',
'is_attention.integer' => '是否关注该收藏商品必须为数字',
'is_attention.between' => '是否关注该收藏商品,1是0否',
];
//场景验证规则
protected $scene = [
'add' => ['user_id', 'goods_id', 'add_time', 'is_attention'],
'edit' => ['user_id', 'goods_id', 'add_time', 'is_attention']
'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;
}
}

110
app/Http/Requests/CommentRequest.php

@ -0,0 +1,110 @@
<?php
namespace App\Http\Requests;
class CommentRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'comment_type' => 'required|integer|between:[0,1]',
'id_value' => 'required|integer',
'comment_rank' => 'required|integer|between:[1,5]',
'add_time' => 'required|integer',
'ip_address' => 'max:20',
'status' => 'integer|between:[0,1]',
'parent_id' => 'integer',
'user_id' => 'required|integer',
'is_anonymous' => 'integer|between:[0,1]',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'comment_type.required' => '用户评论的类型必填',
'comment_type.integer' => '用户评论的类型必须为数字',
'comment_type.between' => '用户评论的类型;0评论的是商品,1评论的是文章',
'id_value.required' => '文章或者商品的id必填',
'id_value.integer' => '文章或者商品的id必须为数字',
'comment_rank.required' => '评价等级必填',
'comment_rank.integer' => '评价等级必须为数字',
'comment_rank.between' => '评价等级,1到5星',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须是数字',
'ip_address.max' => 'IP地址不能超过20个字符',
'status.integer' => '状态必须是数字',
'status.between' => '是否显示;1是;0隐藏',
'parent_id.integer' => '评论的父节点必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'is_anonymous.integer' => '是否匿名必须是数字',
'is_anonymous.between' => '是否匿名,0否',
];
//场景验证规则
protected $scene = [
'add' => ['comment_type', 'id_value', 'comment_rank', 'add_time', 'ip_address', 'status', 'parent_id', 'user_id', 'is_anonymous'],
'edit' => ['comment_type', 'id_value', 'comment_rank', 'add_time', 'ip_address', 'status', 'parent_id', 'user_id', 'is_anonymous'],
'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;
}
}

100
app/Http/Requests/FeedbackRequest.php

@ -1,20 +1,96 @@
<?php
namespace app\common\validate;
namespace App\Http\Requests;
use think\Validate;
class Feedback extends Validate
class FeedbackRequest extends BaseRequest
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['content', 'require','意见反馈内容必填'],
['title', 'max:150','标题必填|标题不能超过150个字符'],
['user_id', 'number', '用户ID必须是数字'],
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'content' => 'required',
'add_time' => 'required|integer',
'title' => 'max:150',
'user_id' => 'integer',
'mobile' => 'max:20',
'type' => 'max:20',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'content.required' => '意见反馈内容必填',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须为数字',
'title.max' => '标题不能超过150个字符',
'user_id.integer' => '发布者ID必须是数字',
'mobile.max' => '手机号码不能超过20个字符',
'type.max' => '意见反馈类型不能超过20个字符',
];
//场景验证规则
protected $scene = [
'add' => ['content', 'title', 'user_id'],
'del' => ['id'],
'add' => ['content', 'add_time', 'title', 'user_id', 'mobile', 'type'],
'edit' => ['content', 'add_time', 'title', 'user_id', 'mobile', 'type'],
'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;
}
}

100
app/Http/Requests/FriendlinkRequest.php

@ -1,21 +1,95 @@
<?php
namespace app\common\validate;
namespace App\Http\Requests;
use think\Validate;
class Friendlink extends Validate
class FriendlinkRequest extends BaseRequest
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['webname', 'require|max:60','链接名称必填|链接名称不能超过60个字符'],
['url', 'max:100','跳转链接不能超过100个字符'],
['group_id', 'number', '分组ID必须是数字'],
['rank', 'number','排序必须是数字'],
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'webname' => 'required|max:60',
'url' => 'required|max:100',
'group_id' => 'integer|between:[1,99]',
'listorder' => 'integer|between:[1,9999]',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'webname.required' => '友情链接名称必填',
'webname.max' => '友情链接名称不能大于60个字',
'url.required' => 'url必填',
'url.max' => 'url不能大于100个字',
'group_id.integer' => '分组id必须是数字',
'group_id.between' => '分组id只能1-99',
'listorder.integer' => '排序必须是数字',
'listorder.between' => '排序只能1-9999',
];
//场景验证规则
protected $scene = [
'add' => ['webname', 'url', 'target', 'group_id', 'rank'],
'del' => ['id'],
'add' => ['webname', 'url', 'group_id', 'listorder'],
'edit' => ['webname', 'url', 'group_id', '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;
}
}

121
app/Http/Requests/GoodsBrandRequest.php

@ -1,28 +1,109 @@
<?php
namespace app\common\validate;
namespace App\Http\Requests;
use think\Validate;
class GoodsBrand extends Validate
class GoodsBrandRequest extends BaseRequest
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['pid', 'number','父级ID必须是数字'],
['add_time', 'number','发布时间格式不正确'],
['title', 'require|max:150','标题必填|标题不能超过150个字符'],
['keywords', 'max:60','关键词不能超过60个字符'],
['seotitle', 'max:150','seo标题不能超过150个字符'],
['description', 'max:250','描述不能超过250个字符'],
['litpic', 'max:100','缩略图不能超过100个字符'],
['status', 'in:0,1','是否显示,0显示'],
['cover_img', 'max:100','封面不能超过100个字符'],
['click', 'number', '点击量必须是数字'],
['listorder', 'number|between:1,9999','排序必须是数字|排序只能1-9999'],
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'pid' => 'integer',
'add_time' => 'required|integer',
'title' => 'required|max:150',
'seotitle' => 'max:150',
'keywords' => 'max:60',
'description' => 'max:240',
'litpic' => 'max:100',
'status' => 'integer|between:[0,1]',
'listorder' => 'integer|between:[1,9999]',
'cover_img' => 'max:100',
'click' => 'integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'pid.integer' => '父级id必须为数字',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须是数字',
'title.required' => '标题必填',
'title.max' => '标题不能超过150个字符',
'seotitle.max' => 'seo标题不能超过150个字符',
'keywords.max' => '关键词不能超过60个字符',
'description.max' => '描述不能超过240个字符',
'litpic.max' => '缩略图不能超过100个字符',
'status.integer' => '是否显示必须是数字',
'status.between' => '是否显示,0显示',
'listorder.integer' => '排序必须是数字',
'listorder.between' => '排序只能1-9999',
'cover_img.max' => '封面不能超过100个字符',
'click.integer' => '点击必须为数字',
];
//场景验证规则
protected $scene = [
'add' => ['pid', 'add_time', 'title', 'keywords', 'seotitle', 'description', 'litpic', 'status', 'cover_img', 'click', 'listorder'],
'del' => ['id'],
'add' => ['pid', 'add_time', 'title', 'seotitle', 'keywords', 'description', 'litpic', 'status', 'listorder', 'cover_img', 'click'],
'edit' => ['pid', 'add_time', 'title', 'seotitle', 'keywords', 'description', 'litpic', 'status', 'listorder', 'cover_img', 'click'],
'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;
}
}

97
app/Http/Requests/GoodsImgRequest.php

@ -0,0 +1,97 @@
<?php
namespace App\Http\Requests;
class GoodsImgRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'url' => 'required|max:150',
'goods_id' => 'required|integer',
'add_time' => 'required|integer',
'des' => 'max:150',
'listorder' => 'integer|between:[1,9999]',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'url.required' => '图片地址必填',
'url.max' => '图片地址不能超过150个字',
'goods_id.required' => '商品id必填',
'goods_id.integer' => '商品id必须为数字',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须是数字',
'des.max' => '图片说明信息不能超过150个字',
'listorder.integer' => '排序必须是数字',
'listorder.between' => '排序只能1-9999',
];
//场景验证规则
protected $scene = [
'add' => ['url', 'goods_id', 'add_time', 'des', 'listorder'],
'edit' => ['url', 'goods_id', 'add_time', 'des', '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;
}
}

20
app/Http/Requests/GoodsRequest.php

@ -8,7 +8,7 @@ class GoodsRequest extends BaseRequest
'id' => 'required|integer',
'title' => 'required|max:150',
'typeid' => 'required|integer',
'click' => 'required|integer',
'click' => 'integer',
'tuijian' => 'integer',
'sn' => 'max:60',
'price' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
@ -18,7 +18,7 @@ class GoodsRequest extends BaseRequest
'keywords' => 'max:60',
'seotitle' => 'max:150',
'description' => 'max:250',
'status' => 'between:[0,5]',
'status' => 'integer|between:[0,5]',
'shipping_fee' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'market_price' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_number' => 'required|integer|between:[1,99999]',
@ -34,17 +34,18 @@ class GoodsRequest extends BaseRequest
'goods_img' => 'max:250',
'warn_number' => 'integer|between:[1,99]',
'listorder' => 'integer|between:[1,9999]',
'brand_id' => 'integer',
];
//总的自定义错误信息
protected $messages = [
'title.max' => '标题不能大于150个字',
'title.required' => '必须填写标题',
'typeid.required' => '栏目ID必填',
'typeid.integer' => '栏目ID必须为数字',
'click.integer' => '点击必须为数字',
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'title.required' => '标题必填',
'title.max' => '标题不能超过150个字符',
'typeid.required' => '栏目ID必填',
'typeid.integer' => '栏目ID必须为数字符',
'click.integer' => '点击量必须为数字',
'tuijian.integer' => '推荐等级必须是数字',
'sn.max' => '货号不能超过60个字符',
'price.required' => '产品价格必填',
@ -57,6 +58,7 @@ class GoodsRequest extends BaseRequest
'keywords.max' => '关键词不能超过60个字符',
'seotitle.max' => 'seo标题不能超过150个字符',
'description.max' => '描述不能超过250个字符',
'status.integer' => '商品状态必须是数字',
'status.between' => '商品状态 0正常 1已删除 2下架 3申请上架',
'shipping_fee.regex' => '运费格式不正确,运费只能带2位小数的数字',
'market_price.required' => '市场价格必填',
@ -86,9 +88,9 @@ class GoodsRequest extends BaseRequest
//场景验证规则
protected $scene = [
'add' => ['typeid', 'title', 'tuijian', 'click', 'sn', 'price', 'litpic', 'pubdate', 'add_time', 'keywords', 'seotitle', 'description', 'status', 'shipping_fee', 'market_price', 'goods_number', 'user_id', 'sale', 'cost_price', 'goods_weight', 'point', 'comments', 'promote_start_date', 'promote_price', 'promote_end_date', 'goods_img', 'warn_number', 'listorder', 'brand_id'],
'add' => ['typeid', 'title', 'tuijian', 'click', 'sn', 'price', 'litpic', 'pubdate', 'add_time', 'keywords', 'seotitle', 'description', 'status', 'shipping_fee', 'market_price', 'goods_number', 'user_id', 'sale', 'cost_price', 'goods_weight', 'point', 'comments', 'promote_start_date', 'promote_price', 'promote_end_date', 'goods_img', 'warn_number', 'listorder', 'brand_id'],
'edit' => ['typeid', 'title', 'tuijian', 'click', 'sn', 'price', 'litpic', 'pubdate', 'add_time', 'keywords', 'seotitle', 'description', 'status', 'shipping_fee', 'market_price', 'goods_number', 'user_id', 'sale', 'cost_price', 'goods_weight', 'point', 'comments', 'promote_start_date', 'promote_price', 'promote_end_date', 'goods_img', 'warn_number', 'listorder', 'brand_id'],
'del' => ['id'],
'del' => ['id'],
];
/**

97
app/Http/Requests/GoodsSearchwordRequest.php

@ -0,0 +1,97 @@
<?php
namespace App\Http\Requests;
class GoodsSearchwordRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'name' => 'required|max:60',
'status' => 'integer|between:[0,5]',
'add_time' => 'required|integer',
'listorder' => 'integer|between:[1,9999]',
'click' => 'integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'name.required' => '标题必填',
'name.max' => '标题不能超过60个字符',
'status.integer' => '状态必须是数字',
'status.between' => '状态 0显示',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须是数字',
'listorder.integer' => '排序必须是数字',
'listorder.between' => '排序只能1-9999',
'click.integer' => '点击必须为数字',
];
//场景验证规则
protected $scene = [
'add' => ['name', 'status', 'add_time', 'listorder', 'click'],
'edit' => ['name', 'status', 'add_time', 'listorder', 'click'],
'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;
}
}

130
app/Http/Requests/GoodsTypeRequest.php

@ -1,31 +1,115 @@
<?php
namespace app\common\validate;
namespace App\Http\Requests;
use think\Validate;
class GoodsType extends Validate
class GoodsTypeRequest extends BaseRequest
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['reid', 'number','父级id必须是数字'],
['addtime', 'number','添加时间必须是数字'],
['name', 'require|max:30','栏目名称必填|栏目名称不能超过30个字符'],
['seotitle', 'max:150','seo标题不能超过150个字符'],
['keywords', 'max:60','关键词不能超过60个字符'],
['description', 'max:250','描述不能超过250个字符'],
['typedir', 'require|max:30','栏目别名必填|栏目别名不能超过30个字符'],
['templist', 'max:50','列表页模板不能超过50个字符'],
['temparticle', 'max:50','文章页模板不能超过50个字符'],
['litpic', 'max:100','缩略图不能超过100个字符'],
['seokeyword', 'max:60','相关关键词不能超过60个字符'],
['status', 'in:0,1','状态 0不显示 1显示'],
['listorder', 'number|between:1,9999','排序必须是数字|排序只能1-9999'],
['cover_img', 'max:100','封面不能超过100个字符'],
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'pid' => 'integer',
'addtime' => 'required|integer',
'name' => 'required|max:30',
'seotitle' => 'max:150',
'keywords' => 'max:60',
'description' => 'max:250',
'typedir' => 'required|max:30',
'templist' => 'max:50',
'temparticle' => 'max:50',
'litpic' => 'max:100',
'seokeyword' => 'max:50',
'status' => 'integer|between:[0,1]',
'listorder' => 'integer',
'cover_img' => 'max:100',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'pid.integer' => '父级id必须是数字',
'addtime.required' => '添加时间必填',
'addtime.integer' => '添加时间必须是数字',
'name.required' => '栏目名称必填',
'name.max' => '栏目名称不能超过30个字符',
'seotitle.max' => 'seo标题不能超过150个字符',
'keywords.max' => '关键词不能超过60个字符',
'description.max' => '描述不能超过250个字符',
'typedir.required' => '栏目别名必填',
'typedir.max' => '栏目别名不能超过30个字符',
'templist.max' => '列表页模板不能超过50个字符',
'temparticle.max' => '文章页模板不能超过50个字符',
'litpic.max' => '缩略图不能超过100个字符',
'seokeyword.max' => 'seokeyword不能超过50个字符',
'status.integer' => '状态必须是数字',
'status.between' => '状态 1显示',
'listorder.integer' => '排序必须是数字',
'cover_img.max' => '封面不能超过100个字符',
];
//场景验证规则
protected $scene = [
'add' => ['reid', 'addtime', 'name', 'seotitle', 'keywords', 'description', 'typedir', 'templist', 'temparticle', 'litpic', 'seokeyword', 'status', 'listorder', 'cover_img'],
'del' => ['id'],
'add' => ['pid', 'addtime', 'name', 'addtime', 'seotitle', 'keywords', 'description', 'typedir', 'templist', 'temparticle', 'litpic', 'seokeyword', 'status', 'listorder', 'cover_img'],
'edit' => ['pid', 'addtime', 'name', 'addtime', 'seotitle', 'keywords', 'description', 'typedir', 'templist', 'temparticle', 'litpic', 'seokeyword', 'status', 'listorder', 'cover_img'],
'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;
}
}

109
app/Http/Requests/GuestbookRequest.php

@ -1,24 +1,101 @@
<?php
namespace app\common\validate;
namespace App\Http\Requests;
use think\Validate;
class Guestbook extends Validate
class GuestbookRequest extends BaseRequest
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['title', 'require|max:150','标题必填|标题不能超过150个字符'],
['msg', 'require|max:250','内容必填|内容不能超过250个字符'],
['name', 'require|max:30','姓名必填|姓名不能超过30个字符'],
['phone', 'require|max:30','电话必填|电话不能超过30个字符'],
['email', 'require|max:60','邮箱必填|邮箱不能超过60个字符'],
['status', 'number', 'status必须是数字'],
['addtime', 'number','添加时间必须是数字'],
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'title' => 'required|max:150',
'addtime' => 'required|integer',
'msg' => 'required|max:250',
'status' => 'integer|between:[0,1]',
'name' => 'max:30',
'phone' => 'max:20',
'email' => 'max:60',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'title.required' => '标题必填',
'title.max' => '标题不能超过150个字符',
'addtime.required' => '添加时间必填',
'addtime.integer' => '添加时间必须是数字',
'msg.required' => '描述必填',
'msg.max' => '描述不能超过250个字符',
'status.integer' => '状态必须是数字',
'status.between' => '是否阅读,默认0未阅读',
'name.max' => '姓名不能超过30个字符',
'phone.max' => '电话不能超过20个字符',
'email.max' => '邮箱不能超过60个字符',
];
//场景验证规则
protected $scene = [
'add' => ['varname', 'info', 'value'],
'del' => ['id'],
'add' => ['title', 'addtime', 'msg', 'status', 'name', 'phone', 'email'],
'edit' => ['title', 'addtime', 'msg', 'status', 'name', 'phone', 'email'],
'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;
}
}

89
app/Http/Requests/KeywordRequest.php

@ -0,0 +1,89 @@
<?php
namespace App\Http\Requests;
class KeywordRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'keyword' => 'required|max:30',
'rpurl' => 'required|max:150',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'keyword.required' => '关键词必填',
'keyword.max' => '关键词不能超过30个字符',
'rpurl.required' => '链接网址必填',
'rpurl.max' => '链接网址不能超过150个字符',
];
//场景验证规则
protected $scene = [
'add' => ['keyword', 'rpurl'],
'edit' => ['keyword', 'rpurl'],
'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;
}
}

105
app/Http/Requests/KuaidiRequest.php

@ -0,0 +1,105 @@
<?php
namespace App\Http\Requests;
class KuaidiRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'name' => 'required|max:30',
'code' => 'required|max:20',
'money' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'country' => 'max:20',
'des' => 'max:150',
'tel' => 'max:60',
'website' => 'max:60',
'status' => 'integer|between:[0,1]',
'listorder' => 'integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'name.required' => '快递公司名称必填',
'name.max' => '快递公司名称不能超过30个字符',
'code.required' => '快递公司编码必填',
'code.max' => '快递公司编码不能超过20个字符',
'money.regex' => '快递费只能带2位小数的数字',
'status.integer' => '状态必须是数字',
'status.between' => '状态 0显示',
'country.max' => '国家编码不能超过20个字符',
'des.max' => '说明不能超过150个字符',
'tel.max' => '电话不能超过60个字符',
'website.max' => '官网不能超过60个字符',
'listorder.integer' => '排序必须是数字',
'listorder.between' => '排序只能1-9999',
];
//场景验证规则
protected $scene = [
'add' => ['name', 'code', 'money', 'country', 'des', 'tel', 'website', 'status', 'listorder'],
'edit' => ['name', 'code', 'money', 'country', 'des', 'tel', 'website', '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;
}
}

105
app/Http/Requests/MenuRequest.php

@ -0,0 +1,105 @@
<?php
namespace App\Http\Requests;
class MenuRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'pid' => 'integer',
'action' => 'required|max:50',
'data' => 'max:50',
'type' => 'integer|between:[0,1]',
'status' => 'integer|between:[0,1]',
'listorder' => 'integer',
'name' => 'required|max:50',
'icon' => 'max:50',
'des' => 'max:250',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'pid.integer' => '父级ID必须为数字',
'action.required' => '操作名称必填',
'action.max' => '操作名称不能超过50个字符',
'data.max' => '额外参数不能超过50个字符',
'type.integer' => '菜单类型必须是数字',
'type.between' => '菜单类型 1:权限认证+菜单;0:只作为菜单',
'status.integer' => '状态必须是数字',
'status.between' => '状态 1显示',
'listorder.integer' => '排序必须是数字',
'name.required' => '菜单名称必填',
'name.max' => '菜单名称不能超过50个字符',
'icon.max' => '菜单图标不能超过50个字符',
'des.max' => '说明不能超过250个字符',
];
//场景验证规则
protected $scene = [
'add' => ['pid', 'action', 'data', 'type', 'status', 'listorder', 'name', 'icon', 'des'],
'edit' => ['pid', 'action', 'data', 'type', 'status', 'listorder', 'name', 'icon', 'des'],
'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;
}
}

155
app/Http/Requests/OrderRequest.php

@ -0,0 +1,155 @@
<?php
namespace App\Http\Requests;
class OrderRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'title' => 'required|max:150',
'typeid' => 'required|integer',
'click' => 'integer',
'tuijian' => 'integer',
'sn' => 'max:60',
'price' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'litpic' => 'required|max:100',
'pubdate' => 'integer',
'add_time' => 'required|integer',
'keywords' => 'max:60',
'seotitle' => 'max:150',
'description' => 'max:250',
'status' => 'integer|between:[0,5]',
'shipping_fee' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'market_price' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_number' => 'required|integer|between:[1,99999]',
'user_id' => 'integer',
'sale' => 'integer|between:[1,99999]',
'cost_price' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_weight' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'point' => 'integer|between:[1,99999]',
'comments' => 'integer|between:[1,99999]',
'promote_start_date' => 'integer',
'promote_end_date' => 'integer',
'promote_price' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_img' => 'max:250',
'warn_number' => 'integer|between:[1,99]',
'listorder' => 'integer|between:[1,9999]',
'brand_id' => 'integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'title.required' => '标题必填',
'title.max' => '标题不能超过150个字符',
'typeid.required' => '栏目ID必填',
'typeid.integer' => '栏目ID必须为数字符',
'click.integer' => '点击必须为数字',
'tuijian.integer' => '推荐等级必须是数字',
'sn.max' => '货号不能超过60个字符',
'price.required' => '产品价格必填',
'price.regex' => '产品价格只能带2位小数的数字',
'litpic.required' => '缩略图必须上传',
'litpic.max' => '缩略图不能超过100个字符',
'pubdate.integer' => '更新时间格式不正确',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须是数字',
'keywords.max' => '关键词不能超过60个字符',
'seotitle.max' => 'seo标题不能超过150个字符',
'description.max' => '描述不能超过250个字符',
'status.integer' => '商品状态必须是数字',
'status.between' => '商品状态 0正常 1已删除 2下架 3申请上架',
'shipping_fee.regex' => '运费格式不正确,运费只能带2位小数的数字',
'market_price.required' => '市场价格必填',
'market_price.regex' => '市场价格格式不正确,市场价格只能带2位小数的数字',
'goods_number.required' => '库存必填',
'goods_number.integer' => '库存必须是数字',
'goods_number.between' => '库存只能1-99999',
'user_id.integer' => '发布者ID必须是数字',
'sale.integer' => '销量必须是数字',
'sale.between' => '销量只能1-99999',
'cost_price.regex' => '成本价格格式不正确,成本价格只能带2位小数的数字',
'goods_weight.regex' => '重量格式不正确,重量只能带2位小数的数字',
'point.integer' => '购买该商品时每笔成功交易赠送的积分数量必须是数字',
'point.between' => '购买该商品时每笔成功交易赠送的积分数量只能1-99999',
'comments.integer' => '评论次数必须是数字',
'comments.between' => '评论次数只能1-9999999',
'promote_start_date.integer' => '促销价格开始日期必须是数字',
'promote_end_date.integer' => '促销价格结束日期必须是数字',
'promote_price.regex' => '促销价格格式不正确,促销价格只能带2位小数的数字',
'goods_img.max' => '商品的实际大小图片不能超过250个字符',
'warn_number.integer' => '商品报警数量必须是数字',
'warn_number.between' => '商品报警数量只能1-99',
'listorder.integer' => '排序必须是数字',
'listorder.between' => '排序只能1-9999',
'brand_id.integer' => '商品品牌ID必须是数字',
];
//场景验证规则
protected $scene = [
'add' => ['typeid', 'title', 'tuijian', 'click', 'sn', 'price', 'litpic', 'pubdate', 'add_time', 'keywords', 'seotitle', 'description', 'status', 'shipping_fee', 'market_price', 'goods_number', 'user_id', 'sale', 'cost_price', 'goods_weight', 'point', 'comments', 'promote_start_date', 'promote_price', 'promote_end_date', 'goods_img', 'warn_number', 'listorder', 'brand_id'],
'edit' => ['typeid', 'title', 'tuijian', 'click', 'sn', 'price', 'litpic', 'pubdate', 'add_time', 'keywords', 'seotitle', 'description', 'status', 'shipping_fee', 'market_price', 'goods_number', 'user_id', 'sale', 'cost_price', 'goods_weight', 'point', 'comments', 'promote_start_date', 'promote_price', 'promote_end_date', 'goods_img', 'warn_number', 'listorder', 'brand_id'],
'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;
}
}

117
app/Http/Requests/PageRequest.php

@ -1,26 +1,107 @@
<?php
namespace app\common\validate;
namespace App\Http\Requests;
use think\Validate;
class Page extends Validate
class PageRequest extends BaseRequest
{
// 验证规则
protected $rule = [
['id', 'require|number','ID必填|ID必须是数字'],
['click', 'number', '点击量必须是数字'],
['title', 'require|max:150','标题必填|标题不能超过150个字符'],
['filename', 'max:60','别名不能超过60个字符'],
['template', 'max:30','模板名称不能超过30个字符'],
['litpic', 'max:100','缩略图不能超过100个字符'],
['pubdate', 'require|number', '更新时间必填|更新时间格式不正确'],
['keywords', 'max:60','关键词不能超过60个字符'],
['seotitle', 'max:150','seo标题不能超过150个字符'],
['description', 'max:250','描述不能超过60个字符'],
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'title' => 'required|max:150',
'seotitle' => 'max:150',
'keywords' => 'max:100',
'description' => 'max:250',
'template' => 'max:30',
'pubdate' => 'required|integer',
'filename' => 'required|max:60',
'litpic' => 'max:100',
'click' => 'integer',
'listorder' => 'integer|between:[1,9999]',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'title.required' => '标题必填',
'title.max' => '标题不能超过150个字符',
'seotitle.max' => 'seo标题不能超过150个字符',
'keywords.max' => '关键词不能超过100个字符',
'description.max' => '描述不能超过250个字符',
'template.max' => '模板名不能超过30个字符',
'pubdate.required' => '时间必填',
'pubdate.integer' => '时间格式不正确',
'filename.required' => '别名必填',
'filename.max' => '别名不能超过60个字符',
'litpic.max' => '缩略图不能超过100个字符',
'click.integer' => '点击量必须为数字',
'listorder.integer' => '排序必须是数字',
'listorder.between' => '排序只能1-9999',
];
//场景验证规则
protected $scene = [
'add' => ['title', 'tuijian', 'click', 'filename', 'template', 'litpic', 'pubdate', 'keywords', 'seotitle', 'description'],
'del' => ['id'],
'add' => ['title', 'seotitle', 'keywords', 'description', 'template', 'pubdate', 'filename', 'litpic', 'click', 'listorder'],
'edit' => ['title', 'seotitle', 'keywords', 'description', 'template', 'pubdate', 'filename', 'litpic', 'click', '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;
}
}

58
lqycms.sql
File diff suppressed because it is too large
View File

Loading…
Cancel
Save