From fa1f28c859ec157f4e0bc2c156db66e20ba8592c Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Tue, 17 Apr 2018 17:30:25 +0800 Subject: [PATCH] article --- .../Controllers/Api/ArticleController.php | 4 + app/Http/Requests/GoodsRequest.php | 2 +- app/Http/Requests/PaymentRequest.php | 104 ++++++++++++++--- app/Http/Requests/RegionRequest.php | 107 ++++++++++++++--- app/Http/Requests/SysconfigRequest.php | 96 ++++++++++++++-- app/Http/Requests/TokenRequest.php | 103 +++++++++++++++-- app/Http/Requests/VerifyCodeRequest.php | 108 +++++++++++++++--- lqycms.sql | 6 +- routes/web.php | 3 + 9 files changed, 463 insertions(+), 70 deletions(-) diff --git a/app/Http/Controllers/Api/ArticleController.php b/app/Http/Controllers/Api/ArticleController.php index 60ecda6..ec52495 100644 --- a/app/Http/Controllers/Api/ArticleController.php +++ b/app/Http/Controllers/Api/ArticleController.php @@ -66,6 +66,8 @@ class ArticleController extends CommonController { if(Helper::isPostRequest()) { + $_POST['user_id'] = Token::$uid; + return $this->getLogic()->add($_POST); } } @@ -79,6 +81,7 @@ class ArticleController extends CommonController { unset($_POST['id']); $where['id'] = $id; + //$where['user_id'] = Token::$uid; return $this->getLogic()->edit($_POST,$where); } @@ -93,6 +96,7 @@ class ArticleController extends CommonController { unset($_POST['id']); $where['id'] = $id; + //$where['user_id'] = Token::$uid; return $this->getLogic()->del($where); } diff --git a/app/Http/Requests/GoodsRequest.php b/app/Http/Requests/GoodsRequest.php index 4c79c8c..59f2596 100644 --- a/app/Http/Requests/GoodsRequest.php +++ b/app/Http/Requests/GoodsRequest.php @@ -44,7 +44,7 @@ class GoodsRequest extends BaseRequest 'title.required' => '标题必填', 'title.max' => '标题不能超过150个字符', 'typeid.required' => '栏目ID必填', - 'typeid.integer' => '栏目ID必须为数字符', + 'typeid.integer' => '栏目ID必须为数字', 'click.integer' => '点击量必须为数字', 'tuijian.integer' => '推荐等级必须是数字', 'sn.max' => '货号不能超过60个字符', diff --git a/app/Http/Requests/PaymentRequest.php b/app/Http/Requests/PaymentRequest.php index ddc4848..616ad4a 100644 --- a/app/Http/Requests/PaymentRequest.php +++ b/app/Http/Requests/PaymentRequest.php @@ -1,22 +1,98 @@ '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'], - 'del' => ['id'], + '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; + } } \ No newline at end of file diff --git a/app/Http/Requests/RegionRequest.php b/app/Http/Requests/RegionRequest.php index 869d0a4..c7cabfb 100644 --- a/app/Http/Requests/RegionRequest.php +++ b/app/Http/Requests/RegionRequest.php @@ -1,22 +1,101 @@ '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'], - 'del' => ['id'], + '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; + } } \ No newline at end of file diff --git a/app/Http/Requests/SysconfigRequest.php b/app/Http/Requests/SysconfigRequest.php index 18b60ad..8f4e6eb 100644 --- a/app/Http/Requests/SysconfigRequest.php +++ b/app/Http/Requests/SysconfigRequest.php @@ -1,20 +1,92 @@ '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'], - 'del' => ['id'], + '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; + } } \ No newline at end of file diff --git a/app/Http/Requests/TokenRequest.php b/app/Http/Requests/TokenRequest.php index ed86160..533cedb 100644 --- a/app/Http/Requests/TokenRequest.php +++ b/app/Http/Requests/TokenRequest.php @@ -1,20 +1,99 @@ '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'], - 'del' => ['id'], + '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; + } } \ No newline at end of file diff --git a/app/Http/Requests/VerifyCodeRequest.php b/app/Http/Requests/VerifyCodeRequest.php index f9f2541..7e4566f 100644 --- a/app/Http/Requests/VerifyCodeRequest.php +++ b/app/Http/Requests/VerifyCodeRequest.php @@ -1,22 +1,102 @@ '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'], - 'del' => ['id'], + '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; + } } \ No newline at end of file diff --git a/lqycms.sql b/lqycms.sql index c5aaf4e..2062fff 100644 --- a/lqycms.sql +++ b/lqycms.sql @@ -683,10 +683,10 @@ insert into `fl_page`(`id`,`title`,`seotitle`,`keywords`,`template`,`descriptio DROP TABLE IF EXISTS `fl_payment`; CREATE TABLE `fl_payment` ( - `id` smallint(3) unsigned NOT NULL AUTO_INCREMENT, + `id` smallint(10) unsigned NOT NULL AUTO_INCREMENT, `pay_code` varchar(20) NOT NULL DEFAULT '' COMMENT '支付方式的英文缩写', `pay_name` varchar(100) NOT NULL DEFAULT '' COMMENT '支付方式名称', - `pay_fee` varchar(10) NOT NULL DEFAULT '0' COMMENT '支付费用', + `pay_fee` decimal(10,1) NOT NULL DEFAULT '0.0' COMMENT '支付费用', `pay_des` text NOT NULL COMMENT '支付方式描述', `pay_config` text NOT NULL COMMENT '支付方式的配置信息,包括商户号和密钥什么的', `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否可用;0否;1是', @@ -697,7 +697,7 @@ CREATE TABLE `fl_payment` ( /*Data for the table `fl_payment` */ -insert into `fl_payment`(`id`,`pay_code`,`pay_name`,`pay_fee`,`pay_des`,`pay_config`,`status`,`listorder`) values (1,'balance','余额支付','0','使用帐户余额支付。只有会员才能使用,通过设置信用额度,可以透支。','a:0:{}',1,0),(2,'weixin','微信','0','微信','a:0:{}',1,0),(3,'alipay','支付宝','0','支付宝','a:0:{}',1,0),(4,'cod','货到付款','0','开通城市:×××\r\n货到付款区域:×××','a:0:{}',0,0),(5,'bank','银行汇款/转帐','0','银行名称\r\n收款人信息:全称 ××× ;帐号或地址 ××× ;开户行 ×××。\r\n注意事项:办理电汇时,请在电汇单“汇款用途”一栏处注明您的订单号。','a:0:{}',0,0); +insert into `fl_payment`(`id`,`pay_code`,`pay_name`,`pay_fee`,`pay_des`,`pay_config`,`status`,`listorder`) values (1,'balance','余额支付','0.0','使用帐户余额支付。只有会员才能使用,通过设置信用额度,可以透支。','a:0:{}',1,0),(2,'weixin','微信','0.0','微信','a:0:{}',1,0),(3,'alipay','支付宝','0.0','支付宝','a:0:{}',1,0),(4,'cod','货到付款','0.0','开通城市:×××\r\n货到付款区域:×××','a:0:{}',0,0),(5,'bank','银行汇款/转帐','0.0','银行名称\r\n收款人信息:全称 ××× ;帐号或地址 ××× ;开户行 ×××。\r\n注意事项:办理电汇时,请在电汇单“汇款用途”一栏处注明您的订单号。','a:0:{}',0,0); /*Table structure for table `fl_refund` */ diff --git a/routes/web.php b/routes/web.php index 441574a..d412c3c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -161,6 +161,9 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web //API接口路由,需token验证 Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web','token']], function () { + Route::post('/article_add', 'ArticleController@articleAdd'); //添加文章 + Route::post('/article_update', 'ArticleController@articleUpdate'); //修改文章 + Route::post('/article_delete', 'ArticleController@articleDelete'); //删除文章 //用户中心 Route::post('/user_signin', 'UserController@signin'); //签到 Route::get('/user_info', 'UserController@userInfo'); //用户详细信息