From 8277ecc0e0ebc372d2a6c3881d307122ef06324e Mon Sep 17 00:00:00 2001 From: herojhc <759242210@qq.com> Date: Fri, 14 Jun 2019 11:35:45 +0800 Subject: [PATCH] fix paginate --- .../2016_07_23_000003_create_contacts_table.php | 1 + src/XinXiHua/SDK/Services/ArticleService.php | 14 ++++++++------ src/XinXiHua/SDK/Services/ContactService.php | 2 +- src/XinXiHua/SDK/Services/DepartmentService.php | 16 +++++++++------- src/XinXiHua/SDK/Services/EmployeeService.php | 16 +++++++++------- src/XinXiHua/SDK/Services/ProductService.php | 16 +++++++++------- src/XinXiHua/SDK/Services/RoleService.php | 2 +- 7 files changed, 38 insertions(+), 29 deletions(-) diff --git a/database/migrations/2016_07_23_000003_create_contacts_table.php b/database/migrations/2016_07_23_000003_create_contacts_table.php index 08398c3..bfb4b53 100644 --- a/database/migrations/2016_07_23_000003_create_contacts_table.php +++ b/database/migrations/2016_07_23_000003_create_contacts_table.php @@ -38,6 +38,7 @@ public function up() $table->boolean('is_linkman')->default(0)->nullable(); $table->boolean('is_supervision')->default(0)->nullable(); $table->string('open_id', 50)->default('')->nullable(); + $table->dateTime('attention_at')->nullable(); $table->timestamps(); }); } diff --git a/src/XinXiHua/SDK/Services/ArticleService.php b/src/XinXiHua/SDK/Services/ArticleService.php index d35f5c6..44d49d1 100644 --- a/src/XinXiHua/SDK/Services/ArticleService.php +++ b/src/XinXiHua/SDK/Services/ArticleService.php @@ -15,13 +15,14 @@ class ArticleService extends BaseService { /** + * @param array $criteria * @param null $corpId * @return mixed * @throws ApiException */ - public function all($corpId = null) + public function all($criteria = [], $corpId = null) { - $response = $this->accessToken->getIsvCorpClient($corpId)->get('/articles'); + $response = $this->accessToken->getIsvCorpClient($corpId)->get('/articles', $criteria); if ($response->isResponseSuccess()) { return $response->getResponseData()['data']; } @@ -32,18 +33,19 @@ public function all($corpId = null) /** * @param int $page * @param int $limit + * @param array $criteria * @param null $corpId * @return mixed * @throws ApiException */ - public function paginate($page = 1, $limit = 20, $corpId = null) + public function paginate($page = 1, $limit = 20, $criteria = [], $corpId = null) { - $response = $this->accessToken->getIsvCorpClient($corpId)->get('/articles', [ + $response = $this->accessToken->getIsvCorpClient($corpId)->get('/articles', array_merge([ 'page' => $page, 'limit' => $limit - ]); + ], $criteria)); if ($response->isResponseSuccess()) { - return $response->getResponseData()['data']; + return $response->getResponseData(); } throw new ApiException($response->getResponseMessage()); } diff --git a/src/XinXiHua/SDK/Services/ContactService.php b/src/XinXiHua/SDK/Services/ContactService.php index 042713a..a920914 100644 --- a/src/XinXiHua/SDK/Services/ContactService.php +++ b/src/XinXiHua/SDK/Services/ContactService.php @@ -50,7 +50,7 @@ public function paginate($page = 1, $limit = 20, $criteria = [], $include = [], 'include' => implode(',', $include) ], $criteria)); if ($response->isResponseSuccess()) { - return $response->getResponseData()['data']; + return $response->getResponseData(); } throw new ApiException($response->getResponseMessage()); } diff --git a/src/XinXiHua/SDK/Services/DepartmentService.php b/src/XinXiHua/SDK/Services/DepartmentService.php index ae1861d..20b2667 100644 --- a/src/XinXiHua/SDK/Services/DepartmentService.php +++ b/src/XinXiHua/SDK/Services/DepartmentService.php @@ -14,16 +14,17 @@ class DepartmentService extends BaseService { /** + * @param array $criteria * @param array $include * @param null $corpId * @return mixed * @throws ApiException */ - public function all($include = [], $corpId = null) + public function all($criteria = [], $include = [], $corpId = null) { - $response = $this->accessToken->getIsvCorpClient($corpId)->get('/departments', [ + $response = $this->accessToken->getIsvCorpClient($corpId)->get('/departments', array_merge([ 'include' => implode(',', $include) - ]); + ]), $criteria); if ($response->isResponseSuccess()) { return $response->getResponseData()['data']; } @@ -34,20 +35,21 @@ public function all($include = [], $corpId = null) /** * @param int $page * @param int $limit + * @param array $criteria * @param array $include * @param null $corpId * @return mixed * @throws ApiException */ - public function paginate($page = 1, $limit = 20, $include = [], $corpId = null) + public function paginate($page = 1, $limit = 20, $criteria = [], $include = [], $corpId = null) { - $response = $this->accessToken->getIsvCorpClient($corpId)->get('/departments', [ + $response = $this->accessToken->getIsvCorpClient($corpId)->get('/departments', array_merge([ 'page' => $page, 'limit' => $limit, 'include' => implode(',', $include) - ]); + ], $criteria)); if ($response->isResponseSuccess()) { - return $response->getResponseData()['data']; + return $response->getResponseData(); } throw new ApiException($response->getResponseMessage()); } diff --git a/src/XinXiHua/SDK/Services/EmployeeService.php b/src/XinXiHua/SDK/Services/EmployeeService.php index 1c3c4b0..62d8827 100644 --- a/src/XinXiHua/SDK/Services/EmployeeService.php +++ b/src/XinXiHua/SDK/Services/EmployeeService.php @@ -14,16 +14,17 @@ class EmployeeService extends BaseService { /** + * @param array $criteria * @param array $include * @param null $corpId * @return mixed * @throws ApiException */ - public function all($include = [], $corpId = null) + public function all($criteria = [], $include = [], $corpId = null) { - $response = $this->accessToken->getIsvCorpClient($corpId)->get('/employees', [ + $response = $this->accessToken->getIsvCorpClient($corpId)->get('/employees', array_merge([ 'include' => implode(',', $include) - ]); + ], $criteria)); if ($response->isResponseSuccess()) { return $response->getResponseData()['data']; } @@ -34,20 +35,21 @@ public function all($include = [], $corpId = null) /** * @param int $page * @param int $limit + * @param array $criteria * @param array $include * @param null $corpId * @return mixed * @throws ApiException */ - public function paginate($page = 1, $limit = 20, $include = [], $corpId = null) + public function paginate($page = 1, $limit = 20, $criteria = [], $include = [], $corpId = null) { - $response = $this->accessToken->getIsvCorpClient($corpId)->get('/employees', [ + $response = $this->accessToken->getIsvCorpClient($corpId)->get('/employees', array_merge([ 'page' => $page, 'limit' => $limit, 'include' => implode(',', $include) - ]); + ], $criteria)); if ($response->isResponseSuccess()) { - return $response->getResponseData()['data']; + return $response->getResponseData(); } throw new ApiException($response->getResponseMessage()); } diff --git a/src/XinXiHua/SDK/Services/ProductService.php b/src/XinXiHua/SDK/Services/ProductService.php index f7508c3..c898277 100644 --- a/src/XinXiHua/SDK/Services/ProductService.php +++ b/src/XinXiHua/SDK/Services/ProductService.php @@ -13,16 +13,17 @@ class ProductService extends BaseService { /** + * @param array $criteria * @param array $include * @param null $corpId * @return mixed * @throws ApiException */ - public function all($include = ['logo'], $corpId = null) + public function all($criteria = [], $include = ['logo'], $corpId = null) { - $response = $this->accessToken->getIsvCorpClient($corpId)->get('/products', [ + $response = $this->accessToken->getIsvCorpClient($corpId)->get('/products', array_merge([ 'include' => implode(',', $include) - ]); + ], $criteria)); if ($response->isResponseSuccess()) { return $response->getResponseData()['data']; } @@ -32,20 +33,21 @@ public function all($include = ['logo'], $corpId = null) /** * @param int $page * @param int $limit + * @param array $criteria * @param array $include * @param null $corpId * @return mixed * @throws ApiException */ - public function paginate($page = 1, $limit = 20, $include = ['logo'], $corpId = null) + public function paginate($page = 1, $limit = 20, $criteria = [], $include = ['logo'], $corpId = null) { - $response = $this->accessToken->getIsvCorpClient($corpId)->get('/products', [ + $response = $this->accessToken->getIsvCorpClient($corpId)->get('/products', array_merge([ 'page' => $page, 'limit' => $limit, 'include' => implode(',', $include) - ]); + ], $criteria)); if ($response->isResponseSuccess()) { - return $response->getResponseData()['data']; + return $response->getResponseData(); } throw new ApiException($response->getResponseMessage()); } diff --git a/src/XinXiHua/SDK/Services/RoleService.php b/src/XinXiHua/SDK/Services/RoleService.php index 22b3934..eaeaf22 100644 --- a/src/XinXiHua/SDK/Services/RoleService.php +++ b/src/XinXiHua/SDK/Services/RoleService.php @@ -50,7 +50,7 @@ public function paginate($page = 1, $limit = 20, $criteria = [], $include = [], 'include' => implode(',', $include) ], $criteria)); if ($response->isResponseSuccess()) { - return $response->getResponseData()['data']; + return $response->getResponseData(); } throw new ApiException($response->getResponseMessage()); }