From e0fea97d0245842927419ff2ce02956c063e7971 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Sun, 30 Jun 2019 00:50:00 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=AE=8C=E5=96=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/InterfaceList.php | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/application/admin/controller/InterfaceList.php b/application/admin/controller/InterfaceList.php index a5051f4..47a2124 100644 --- a/application/admin/controller/InterfaceList.php +++ b/application/admin/controller/InterfaceList.php @@ -29,25 +29,24 @@ class InterfaceList extends Base { $type = $this->request->get('type', ''); $status = $this->request->get('status', ''); - $where = []; - if ($status === '1' || $status === '0') { - $where['status'] = $status; + $obj = new AdminList(); + if (strlen($status)) { + $obj = $obj->where('status', $status); } if ($type) { switch ($type) { case 1: - $where['hash'] = $keywords; + $obj = $obj->where('hash', $keywords); break; case 2: - $where['info'] = ['like', "%{$keywords}%"]; + $obj = $obj->whereLike('info', "%{$keywords}%"); break; case 3: - $where['apiClass'] = ['like', "%{$keywords}%"]; + $obj = $obj->whereLike('api_class', "%{$keywords}%"); break; } } - $listObj = (new AdminList())->where($where)->order('id', 'DESC') - ->paginate($limit, false, ['page' => $start])->toArray(); + $listObj = $obj->order('id', 'DESC')->paginate($limit, false, ['page' => $start])->toArray(); return $this->buildSuccess([ 'list' => $listObj['data'], @@ -57,8 +56,8 @@ class InterfaceList extends Base { /** * 获取接口唯一标识 - * @author zhaoxiang * @return array + * @author zhaoxiang */ public function getHash() { $res['hash'] = uniqid(); @@ -73,7 +72,7 @@ class InterfaceList extends Base { */ public function add() { $postData = $this->request->post(); - if (!preg_match("/^[A-Za-z0-9_\/]+$/", $postData['apiClass'])) { + if (!preg_match("/^[A-Za-z0-9_\/]+$/", $postData['api_class'])) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '真实类名只允许填写字母,数字和/'); } @@ -114,7 +113,7 @@ class InterfaceList extends Base { */ public function edit() { $postData = $this->request->post(); - if (!preg_match("/^[A-Za-z0-9_\/]+$/", $postData['apiClass'])) { + if (!preg_match("/^[A-Za-z0-9_\/]+$/", $postData['api_class'])) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '真实类名只允许填写字母,数字和/'); } @@ -172,9 +171,9 @@ class InterfaceList extends Base { /** * 刷新接口路由 - * @author zhaoxiang * @return array * @throws \think\exception\DbException + * @author zhaoxiang */ public function refresh() { $apiRoutePath = ROOT_PATH . 'application/apiRoute.php';