Browse Source

article

master
ZLW-PC\Administrator 6 years ago
parent
commit
fa1f28c859
  1. 4
      app/Http/Controllers/Api/ArticleController.php
  2. 2
      app/Http/Requests/GoodsRequest.php
  3. 104
      app/Http/Requests/PaymentRequest.php
  4. 107
      app/Http/Requests/RegionRequest.php
  5. 96
      app/Http/Requests/SysconfigRequest.php
  6. 103
      app/Http/Requests/TokenRequest.php
  7. 108
      app/Http/Requests/VerifyCodeRequest.php
  8. 6
      lqycms.sql
  9. 3
      routes/web.php

4
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);
}

2
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个字符',

104
app/Http/Requests/PaymentRequest.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'],
'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;
}
}

107
app/Http/Requests/RegionRequest.php

@ -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'],
'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;
}
}

96
app/Http/Requests/SysconfigRequest.php

@ -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'],
'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;
}
}

103
app/Http/Requests/TokenRequest.php

@ -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'],
'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;
}
}

108
app/Http/Requests/VerifyCodeRequest.php

@ -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'],
'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;
}
}

6
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` */

3
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'); //用户详细信息

Loading…
Cancel
Save