From 8edc331577c98bdad79baa3bbd7b06d3f7ab3e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=80=E5=B3=B0?= <1feng.0595@gmail.com> Date: Fri, 11 Aug 2017 00:27:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=84=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/CommentController.php | 5 +- app/Http/Model/Comment.php | 2 +- app/Http/Model/UserWithdraw.php | 86 +++++++++++++++++++ composer.lock | 20 ++--- 4 files changed, 101 insertions(+), 12 deletions(-) create mode 100644 app/Http/Model/UserWithdraw.php diff --git a/app/Http/Controllers/Api/CommentController.php b/app/Http/Controllers/Api/CommentController.php index 44de235..e2c4983 100644 --- a/app/Http/Controllers/Api/CommentController.php +++ b/app/Http/Controllers/Api/CommentController.php @@ -5,6 +5,7 @@ use App\Http\Controllers\Api\CommonController; use Illuminate\Http\Request; use App\Common\ReturnData; use App\Common\Token; +use App\Common\Helper; use App\Http\Model\Comment; class CommentController extends CommonController @@ -46,6 +47,7 @@ class CommentController extends CommonController if($request->input('parent_id', null) !== null){$data['parent_id'] = $request->input('parent_id');} $data['add_time'] = time(); $data['user_id'] = Token::$uid; + $data['ip_address'] = Helper::getRemoteIp(); if($data['comment_type']===null || $data['id_value']===null || $data['content']===null || $data['comment_rank']===null) { @@ -75,8 +77,9 @@ class CommentController extends CommonController if($request->input('parent_id', null) !== null){$data['parent_id'] = $request->input('parent_id');} $data['add_time'] = time(); $data['user_id'] = Token::$uid; + $data['ip_address'] = Helper::getRemoteIp(); - if($id===null || $data['comment_type']===null || $data['id_value']===null || $data['content']===null || $data['comment_rank']===null) + if($id===null) { return ReturnData::create(ReturnData::PARAMS_ERROR); } diff --git a/app/Http/Model/Comment.php b/app/Http/Model/Comment.php index 49b5418..d76d858 100644 --- a/app/Http/Model/Comment.php +++ b/app/Http/Model/Comment.php @@ -24,7 +24,7 @@ class Comment extends BaseModel { extract($param); //参数:limit,offset - $where['user_id'] = Token::$uid; + $where['user_id'] = $user_id; $where['comment_type'] = $comment_type; //0商品评价,1文章评价 $where['status'] = self::SHOW_COMMENT; diff --git a/app/Http/Model/UserWithdraw.php b/app/Http/Model/UserWithdraw.php new file mode 100644 index 0000000..0066d87 --- /dev/null +++ b/app/Http/Model/UserWithdraw.php @@ -0,0 +1,86 @@ +where($where); + + $res['count'] = $model->count(); + $res['list'] = array(); + + if($res['count']>0) + { + $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray(); + } + else + { + return false; + } + + return $res; + } + + public static function getOne($id) + { + return self::where('id', $id)->first()->toArray(); + } + + public static function add(array $data) + { + if ($id = self::insertGetId($data)) + { + return $id; + } + + return false; + } + + public static function modify($where, array $data) + { + if (self::where($where)->update($data)) + { + return true; + } + + return false; + } + + //删除一条记录 + public static function remove($id) + { + if (!self::whereIn('id', explode(',', $id))->delete()) + { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index 3587774..bae2760 100644 --- a/composer.lock +++ b/composer.lock @@ -1332,16 +1332,16 @@ }, { "name": "overtrue/socialite", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/overtrue/socialite.git", - "reference": "0b943f2b2063c8c4f1672b4d2f4451e57d7415a7" + "reference": "fda55f0acef43a144799b1957a8f93d9f5deffce" }, "dist": { "type": "zip", - "url": "https://files.phpcomposer.com/files/overtrue/socialite/0b943f2b2063c8c4f1672b4d2f4451e57d7415a7.zip", - "reference": "0b943f2b2063c8c4f1672b4d2f4451e57d7415a7", + "url": "https://files.phpcomposer.com/files/overtrue/socialite/fda55f0acef43a144799b1957a8f93d9f5deffce.zip", + "reference": "fda55f0acef43a144799b1957a8f93d9f5deffce", "shasum": "" }, "require": { @@ -1378,7 +1378,7 @@ "wechat", "weibo" ], - "time": "2017-07-27T08:22:56+00:00" + "time": "2017-08-04T06:28:22+00:00" }, { "name": "overtrue/wechat", @@ -3324,16 +3324,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.2.1", + "version": "3.2.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "183824db76118b9dddffc7e522b91fa175f75119" + "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157" }, "dist": { "type": "zip", - "url": "https://files.phpcomposer.com/files/phpDocumentor/ReflectionDocBlock/183824db76118b9dddffc7e522b91fa175f75119.zip", - "reference": "183824db76118b9dddffc7e522b91fa175f75119", + "url": "https://files.phpcomposer.com/files/phpDocumentor/ReflectionDocBlock/4aada1f93c72c35e22fb1383b47fee43b8f1d157.zip", + "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157", "shasum": "" }, "require": { @@ -3365,7 +3365,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-04T20:55:59+00:00" + "time": "2017-08-08T06:39:58+00:00" }, { "name": "phpdocumentor/type-resolver",