diff --git a/application/admin/controller/App.php b/application/admin/controller/App.php index 32a09b2e26c3e2a32d9d3d4776e6a86e46cffd9b..ae8f984be8c5d00159437b6976bf1b749d2aa298 100644 --- a/application/admin/controller/App.php +++ b/application/admin/controller/App.php @@ -7,7 +7,6 @@ namespace app\admin\controller; - use app\model\AdminApp; use app\model\AdminList; use app\model\AdminGroup; @@ -16,6 +15,7 @@ use app\util\Strs; use app\util\Tools; class App extends Base { + /** * 获取应用列表 * @return array @@ -23,7 +23,6 @@ class App extends Base { * @author zhaoxiang */ public function index() { - $limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT')); $start = $this->request->get('page', 1); $keywords = $this->request->get('keywords', ''); @@ -44,7 +43,7 @@ class App extends Base { break; } } - $listObj = $obj->order('app_add_time DESC')->paginate($limit, false, ['page' => $start])->toArray(); + $listObj = $obj->order('app_add_time', 'DESC')->paginate($limit, false, ['page' => $start])->toArray(); return $this->buildSuccess([ 'list' => $listObj['data'], @@ -103,9 +102,9 @@ class App extends Base { 'app_name' => $postData['app_name'], 'app_info' => $postData['app_info'], 'app_group' => $postData['app_group'], - 'app_add_time' => time(), + 'app_add_time' => time(), 'app_api' => '', - 'app_api_show' => '', + 'app_api_show' => '' ]; if (isset($postData['app_api']) && $postData['app_api']) { $appApi = []; @@ -118,9 +117,9 @@ class App extends Base { $res = AdminApp::create($data); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -132,21 +131,19 @@ class App extends Base { $id = $this->request->get('id'); $status = $this->request->get('status'); $res = AdminApp::update([ + 'id' => $id, 'app_status' => $status - ], [ - 'id' => $id ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - $appInfo = AdminApp::get($id); - cache('AccessToken:' . $appInfo['app_secret'], null); - if($oldWiki = cache('WikiLogin:' . $id)) { - cache('WikiLogin:' . $oldWiki, null); - } - - return $this->buildSuccess(); } + $appInfo = AdminApp::get($id); + cache('AccessToken:' . $appInfo['app_secret'], null); + if($oldWiki = cache('WikiLogin:' . $id)) { + cache('WikiLogin:' . $oldWiki, null); + } + + return $this->buildSuccess(); } /** @@ -157,12 +154,12 @@ class App extends Base { public function edit() { $postData = $this->request->post(); $data = [ + 'app_secret' => $postData['app_secret'], 'app_name' => $postData['app_name'], 'app_info' => $postData['app_info'], 'app_group' => $postData['app_group'], - 'app_secret' => $postData['app_secret'], 'app_api' => '', - 'app_api_show' => '', + 'app_api_show' => '' ]; if (isset($postData['app_api']) && $postData['app_api']) { $appApi = []; @@ -175,15 +172,15 @@ class App extends Base { $res = AdminApp::update($data, ['id' => $postData['id']]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - $appInfo = AdminApp::get($postData['id']); - cache('AccessToken:' . $appInfo['app_secret'], null); - if($oldWiki = cache('WikiLogin:' . $postData['id'])) { - cache('WikiLogin:' . $oldWiki, null); - } - - return $this->buildSuccess(); } + $appInfo = AdminApp::get($postData['id']); + cache('AccessToken:' . $appInfo['app_secret'], null); + if($oldWiki = cache('WikiLogin:' . $postData['id'])) { + cache('WikiLogin:' . $oldWiki, null); + } + + return $this->buildSuccess(); + } /** diff --git a/application/admin/controller/AppGroup.php b/application/admin/controller/AppGroup.php index c8f6a7ef03a284d001cd5ad37c45052afe4084f7..a7d7d642e948718f3940f9373d6da36d3b13f44e 100644 --- a/application/admin/controller/AppGroup.php +++ b/application/admin/controller/AppGroup.php @@ -7,13 +7,12 @@ namespace app\admin\controller; - use app\model\AdminApp; use app\model\AdminAppGroup; use app\util\ReturnCode; -use app\util\Tools; class AppGroup extends Base { + /** * 获取应用组列表 * @return array @@ -75,15 +74,14 @@ class AppGroup extends Base { $id = $this->request->get('id'); $status = $this->request->get('status'); $res = AdminAppGroup::update([ + 'id' => $id, 'status' => $status - ], [ - 'id' => $id ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -96,9 +94,9 @@ class AppGroup extends Base { $res = AdminAppGroup::create($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -111,9 +109,9 @@ class AppGroup extends Base { $res = AdminAppGroup::update($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** diff --git a/application/admin/controller/Auth.php b/application/admin/controller/Auth.php index cce7462dd068dacb019a87adda2ffbbdc6450e10..cfe96238abb9b71ff07bb806899419ca02cac8aa 100644 --- a/application/admin/controller/Auth.php +++ b/application/admin/controller/Auth.php @@ -7,7 +7,6 @@ namespace app\admin\controller; - use app\model\AdminAuthGroup; use app\model\AdminAuthGroupAccess; use app\model\AdminAuthRule; @@ -24,7 +23,6 @@ class Auth extends Base { * @author zhaoxiang */ public function index() { - $limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT')); $start = $this->request->get('page', 1); $keywords = $this->request->get('keywords', ''); @@ -38,7 +36,7 @@ class Auth extends Base { $obj = $obj->whereLike('name', "%{$keywords}%"); } - $listObj = $obj->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'], @@ -76,7 +74,7 @@ class Auth extends Base { public function getRuleList() { $groupId = $this->request->get('group_id', 0); - $list = (new AdminMenu)->where([])->order('sort', 'ASC')->select(); + $list = (new AdminMenu)->order('sort', 'ASC')->select(); $list = Tools::buildArrFromObj($list); $list = Tools::listToTree($list); @@ -110,22 +108,21 @@ class Auth extends Base { $res = AdminAuthGroup::create($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - if ($rules) { - $insertData = []; - foreach ($rules as $value) { - if ($value) { - $insertData[] = [ - 'group_id' => $res->id, - 'url' => $value - ]; - } + } + if ($rules) { + $insertData = []; + foreach ($rules as $value) { + if ($value) { + $insertData[] = [ + 'group_id' => $res->id, + 'url' => $value + ]; } - (new AdminAuthRule())->saveAll($insertData); } - - return $this->buildSuccess(); + (new AdminAuthRule())->saveAll($insertData); } + + return $this->buildSuccess(); } /** @@ -142,9 +139,9 @@ class Auth extends Base { ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -165,9 +162,9 @@ class Auth extends Base { $res = AdminAuthGroup::update($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -227,9 +224,9 @@ class Auth extends Base { ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -291,5 +288,4 @@ class Auth extends Base { (new AdminAuthRule())->whereIn('url', $urlArr)->where('group_id', $postData['id'])->delete(); } } - } diff --git a/application/admin/controller/Base.php b/application/admin/controller/Base.php index ee8996d62fc490fd1ec31cd715981054defeaec4..52f7cf6d0b39e7cd8620b4be4093b7edb78db409 100644 --- a/application/admin/controller/Base.php +++ b/application/admin/controller/Base.php @@ -74,5 +74,4 @@ class Base extends Controller { $this->debug[] = $data; } } - } diff --git a/application/admin/controller/Fields.php b/application/admin/controller/Fields.php index fe51246887332bbf21f4eab1c8738b9be9ee241b..c9b6778def40630105c4f67f89f7056c6dd3fba6 100644 --- a/application/admin/controller/Fields.php +++ b/application/admin/controller/Fields.php @@ -7,7 +7,6 @@ namespace app\admin\controller; - use app\model\AdminFields; use app\model\AdminList; use app\util\DataType; @@ -15,6 +14,7 @@ use app\util\ReturnCode; use app\util\Tools; class Fields extends Base { + private $dataType = array( DataType::TYPE_INTEGER => 'Integer', DataType::TYPE_STRING => 'String', @@ -42,21 +42,20 @@ class Fields extends Base { $start = $this->request->get('page', 1); $hash = $this->request->get('hash', ''); - if (!empty($hash)) { - $listObj = (new AdminFields())->where(['hash' => $hash, 'type' => 0]) - ->paginate($limit, false, ['page' => $start])->toArray(); - - $apiInfo = (new AdminList())->where('hash', $hash)->find(); - - return $this->buildSuccess([ - 'list' => $listObj['data'], - 'count' => $listObj['total'], - 'dataType' => $this->dataType, - 'apiInfo' => $apiInfo - ]); - } else { + if (empty($hash)) { return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); } + $listObj = (new AdminFields())->where(['hash' => $hash, 'type' => 0]) + ->paginate($limit, false, ['page' => $start])->toArray(); + + $apiInfo = (new AdminList())->where('hash', $hash)->find(); + + return $this->buildSuccess([ + 'list' => $listObj['data'], + 'count' => $listObj['total'], + 'dataType' => $this->dataType, + 'apiInfo' => $apiInfo + ]); } /** @@ -70,21 +69,20 @@ class Fields extends Base { $start = $this->request->get('page', 1); $hash = $this->request->get('hash', ''); - if (!empty($hash)) { - $listObj = (new AdminFields())->where(['hash' => $hash, 'type' => 1]) - ->paginate($limit, false, ['page' => $start])->toArray(); - - $apiInfo = (new AdminList())->where('hash', $hash)->find(); - - return $this->buildSuccess([ - 'list' => $listObj['data'], - 'count' => $listObj['total'], - 'dataType' => $this->dataType, - 'apiInfo' => $apiInfo - ]); - } else { + if (empty($hash)) { return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); } + $listObj = (new AdminFields())->where(['hash' => $hash, 'type' => 1]) + ->paginate($limit, false, ['page' => $start])->toArray(); + + $apiInfo = (new AdminList())->where('hash', $hash)->find(); + + return $this->buildSuccess([ + 'list' => $listObj['data'], + 'count' => $listObj['total'], + 'dataType' => $this->dataType, + 'apiInfo' => $apiInfo + ]); } /** @@ -105,9 +103,9 @@ class Fields extends Base { if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -128,9 +126,9 @@ class Fields extends Base { if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -208,10 +206,10 @@ class Fields extends Base { $addArr = array( 'field_name' => $index, 'show_name' => $prefix, - 'hash' => $this->request->post('hash'), + 'hash' => $this->request->post('hash'), 'is_must' => 1, 'data_type' => DataType::TYPE_ARRAY, - 'type' => $this->request->post('type') + 'type' => $this->request->post('type') ); $dataArr[] = $addArr; $prefix .= '[]'; @@ -222,10 +220,10 @@ class Fields extends Base { $addArr = array( 'field_name' => $index, 'show_name' => $prefix, - 'hash' => $this->request->post('hash'), + 'hash' => $this->request->post('hash'), 'is_must' => 1, 'data_type' => DataType::TYPE_OBJECT, - 'type' => $this->request->post('type') + 'type' => $this->request->post('type') ); $dataArr[] = $addArr; $prefix .= '{}'; @@ -234,10 +232,10 @@ class Fields extends Base { $addArr = array( 'field_name' => $index, 'show_name' => $myPre, - 'hash' => $this->request->post('hash'), + 'hash' => $this->request->post('hash'), 'is_must' => 1, 'data_type' => DataType::TYPE_STRING, - 'type' => $this->request->post('type') + 'type' => $this->request->post('type') ); if (is_numeric($datum)) { if (preg_match('/^\d*$/', $datum)) { diff --git a/application/admin/controller/InterfaceGroup.php b/application/admin/controller/InterfaceGroup.php index 9bbf7975371fc1d6aa675d3e29f9aa736ca68130..ed3c94aa0d9cbe9a449a3fd99d68821d53c37c78 100644 --- a/application/admin/controller/InterfaceGroup.php +++ b/application/admin/controller/InterfaceGroup.php @@ -7,14 +7,13 @@ namespace app\admin\controller; - use app\model\AdminApp; use app\model\AdminGroup; use app\model\AdminList; use app\util\ReturnCode; -use app\util\Tools; class InterfaceGroup extends Base { + /** * 获取接口组列表 * @return array @@ -42,7 +41,7 @@ class InterfaceGroup extends Base { break; } } - $listObj = $obj->order('create_time desc')->paginate($limit, false, ['page' => $start])->toArray(); + $listObj = $obj->order('create_time', 'desc')->paginate($limit, false, ['page' => $start])->toArray(); return $this->buildSuccess([ 'list' => $listObj['data'], @@ -74,15 +73,14 @@ class InterfaceGroup extends Base { $id = $this->request->get('id'); $status = $this->request->get('status'); $res = AdminGroup::update([ - 'status' => $status - ], [ - 'id' => $id + 'id' => $id, + 'status' => $status, ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -95,9 +93,9 @@ class InterfaceGroup extends Base { $res = AdminGroup::create($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -110,9 +108,9 @@ class InterfaceGroup extends Base { $res = AdminGroup::update($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** diff --git a/application/admin/controller/InterfaceList.php b/application/admin/controller/InterfaceList.php index 64b39cf50c4774d50269ca7c19091c5e6b9d44f2..320b1c49f7f25959bb10ccf64b3684d7318f6033 100644 --- a/application/admin/controller/InterfaceList.php +++ b/application/admin/controller/InterfaceList.php @@ -7,7 +7,6 @@ namespace app\admin\controller; - use app\model\AdminApp; use app\model\AdminFields; use app\model\AdminList; @@ -15,6 +14,7 @@ use app\util\ReturnCode; use think\facade\Env; class InterfaceList extends Base { + /** * 获取接口列表 * @return array @@ -22,7 +22,6 @@ class InterfaceList extends Base { * @author zhaoxiang */ public function index() { - $limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT')); $start = $this->request->get('page', 1); $keywords = $this->request->get('keywords', ''); @@ -79,9 +78,9 @@ class InterfaceList extends Base { $res = AdminList::create($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -99,11 +98,10 @@ class InterfaceList extends Base { ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - cache('ApiInfo:' . $hash, null); - - return $this->buildSuccess(); } + cache('ApiInfo:' . $hash, null); + + return $this->buildSuccess(); } /** @@ -120,11 +118,10 @@ class InterfaceList extends Base { $res = AdminList::update($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - cache('ApiInfo:' . $postData['hash'], null); - - return $this->buildSuccess(); } + cache('ApiInfo:' . $postData['hash'], null); + + return $this->buildSuccess(); } /** diff --git a/application/admin/controller/Log.php b/application/admin/controller/Log.php index be8e98f214eca8e01984e4deee2fcb679a1c3b1a..b6f5e2b9c5304ffed515cb336e3a5c80b3fd79a7 100644 --- a/application/admin/controller/Log.php +++ b/application/admin/controller/Log.php @@ -7,13 +7,8 @@ namespace app\admin\controller; - -use app\model\AdminAuthGroupAccess; -use app\model\AdminUser; use app\model\AdminUserAction; -use app\model\AdminUserData; use app\util\ReturnCode; -use app\util\Tools; class Log extends Base { @@ -24,7 +19,6 @@ class Log extends Base { * @author zhaoxiang */ public function index() { - $limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT')); $start = $this->request->get('page', 1); $type = $this->request->get('type', ''); @@ -44,7 +38,7 @@ class Log extends Base { break; } } - $listObj = $obj->order('add_time DESC')->paginate($limit, false, ['page' => $start])->toArray(); + $listObj = $obj->order('add_time', 'DESC')->paginate($limit, false, ['page' => $start])->toArray(); return $this->buildSuccess([ 'list' => $listObj['data'], @@ -65,7 +59,5 @@ class Log extends Base { AdminUserAction::destroy($id); return $this->buildSuccess(); - } - } diff --git a/application/admin/controller/Login.php b/application/admin/controller/Login.php index 9eac7145d02d164563a0cfe761abb21a0eaeea35..b7efe7ed1243199301b329fc1a77355ac40988e9 100644 --- a/application/admin/controller/Login.php +++ b/application/admin/controller/Login.php @@ -7,7 +7,6 @@ namespace app\admin\controller; - use app\model\AdminAuthGroupAccess; use app\model\AdminAuthRule; use app\model\AdminMenu; @@ -121,5 +120,4 @@ class Login extends Base { } } } - } diff --git a/application/admin/controller/Menu.php b/application/admin/controller/Menu.php index 784f73a147f6a19a88739bd925f986a739158654..14187061d34f03a5063a8cc0b4fe4c505dbc88da 100644 --- a/application/admin/controller/Menu.php +++ b/application/admin/controller/Menu.php @@ -7,7 +7,6 @@ namespace app\admin\controller; - use app\model\AdminMenu; use app\util\ReturnCode; use app\util\Tools; @@ -21,7 +20,7 @@ class Menu extends Base { * @author zhaoxiang */ public function index() { - $list = (new AdminMenu)->where([])->order('sort', 'ASC')->select(); + $list = (new AdminMenu)->order('sort', 'ASC')->select(); $list = Tools::buildArrFromObj($list); $list = Tools::formatTree(Tools::listToTree($list)); @@ -62,9 +61,9 @@ class Menu extends Base { ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -80,9 +79,9 @@ class Menu extends Base { $res = AdminMenu::update($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - return $this->buildSuccess(); } + + return $this->buildSuccess(); } /** @@ -98,11 +97,9 @@ class Menu extends Base { $childNum = AdminMenu::where(['fid' => $id])->count(); if ($childNum) { return $this->buildFailed(ReturnCode::INVALID, '当前菜单存在子菜单,不可以被删除!'); - } else { - AdminMenu::destroy($id); - - return $this->buildSuccess(); } - } + AdminMenu::destroy($id); + return $this->buildSuccess(); + } } diff --git a/application/admin/controller/Miss.php b/application/admin/controller/Miss.php index dd325287195bd13bf59576825c0bbed7af127922..32901302b0ed608e29f461db30a4497b867027da 100644 --- a/application/admin/controller/Miss.php +++ b/application/admin/controller/Miss.php @@ -1,9 +1,11 @@ request->isOptions()) { return $this->buildSuccess(); diff --git a/application/admin/controller/ThirdLogin.php b/application/admin/controller/ThirdLogin.php index ddddc433a01f4e466fc2942db5d1abe81a751fe1..bd175cd80cefc1cf88ad9fce4b7111c1214fa6a4 100644 --- a/application/admin/controller/ThirdLogin.php +++ b/application/admin/controller/ThirdLogin.php @@ -7,7 +7,6 @@ namespace app\admin\controller; - use app\model\AdminAuthGroupAccess; use app\model\AdminUser; use app\util\ReturnCode; @@ -297,7 +296,6 @@ class ThirdLogin extends Base { * @author zhaoxiang */ private function doLogin($openid, $userDetail) { - $userInfo = AdminUser::get(['openid' => $openid]); if (empty($userInfo)) { $userInfo = AdminUser::create([ @@ -345,5 +343,4 @@ class ThirdLogin extends Base { return $this->buildSuccess($userInfo, '登录成功'); } - } diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index 97e1401df8c01b8e93d084e3508674ed59d3b77c..da95c4987f8dd47613c7c6d8ea687d5f8afeba65 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -7,7 +7,6 @@ namespace app\admin\controller; - use app\model\AdminAuthGroupAccess; use app\model\AdminUser; use app\model\AdminUserData; @@ -24,7 +23,6 @@ class User extends Base { * @author zhaoxiang */ public function index() { - $limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT')); $start = $this->request->get('page', 1); $type = $this->request->get('type', '', 'intval'); @@ -46,7 +44,7 @@ class User extends Base { } } - $listObj = $obj->order('create_time DESC') + $listObj = $obj->order('create_time', 'DESC') ->paginate($limit, false, ['page' => $start])->each(function($item, $key){ $item->userData; })->toArray(); @@ -96,14 +94,13 @@ class User extends Base { $res = AdminUser::create($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - AdminAuthGroupAccess::create([ - 'uid' => $res->id, - 'group_id' => $groups - ]); - - return $this->buildSuccess(); } + AdminAuthGroupAccess::create([ + 'uid' => $res->id, + 'group_id' => $groups + ]); + + return $this->buildSuccess(); } /** @@ -161,13 +158,12 @@ class User extends Base { ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - if($oldAdmin = cache('Login:' . $id)) { - cache('Login:' . $oldAdmin, null); - } - - return $this->buildSuccess(); } + if($oldAdmin = cache('Login:' . $id)) { + cache('Login:' . $oldAdmin, null); + } + + return $this->buildSuccess(); } /** @@ -191,26 +187,25 @@ class User extends Base { $res = AdminUser::update($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); + } + $has = AdminAuthGroupAccess::get(['uid' => $postData['id']]); + if ($has) { + AdminAuthGroupAccess::update([ + 'group_id' => $groups + ], [ + 'uid' => $postData['id'], + ]); } else { - $has = AdminAuthGroupAccess::get(['uid' => $postData['id']]); - if ($has) { - AdminAuthGroupAccess::update([ - 'group_id' => $groups - ], [ - 'uid' => $postData['id'], - ]); - } else { - AdminAuthGroupAccess::create([ - 'uid' => $postData['id'], - 'group_id' => $groups - ]); - } - if($oldAdmin = cache('Login:' . $postData['id'])) { - cache('Login:' . $oldAdmin, null); - } - - return $this->buildSuccess(); + AdminAuthGroupAccess::create([ + 'uid' => $postData['id'], + 'group_id' => $groups + ]); + } + if($oldAdmin = cache('Login:' . $postData['id'])) { + cache('Login:' . $oldAdmin, null); } + + return $this->buildSuccess(); } /** @@ -240,16 +235,15 @@ class User extends Base { $res = AdminUser::update($postData); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR); - } else { - $userData = AdminUserData::get(['uid' => $postData['id']]); - $userData->head_img = $headImg; - $userData->save(); - if($oldWiki = cache('WikiLogin:' . $postData['id'])) { - cache('WikiLogin:' . $oldWiki, null); - } - - return $this->buildSuccess(); } + $userData = AdminUserData::get(['uid' => $postData['id']]); + $userData->head_img = $headImg; + $userData->save(); + if($oldWiki = cache('WikiLogin:' . $postData['id'])) { + cache('WikiLogin:' . $oldWiki, null); + } + + return $this->buildSuccess(); } /** @@ -274,7 +268,5 @@ class User extends Base { } return $this->buildSuccess(); - } - } diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php index 3cf4c5d2c8a91ac7e498163fbf5c74383d66a476..27080105250c0816dd2fc3b332e31e262f97e464 100644 --- a/application/api/controller/Base.php +++ b/application/api/controller/Base.php @@ -7,7 +7,6 @@ namespace app\api\controller; - use app\util\ReturnCode; use think\Controller; @@ -51,5 +50,4 @@ class Base extends Controller { $this->debug[] = $data; } } - } diff --git a/application/api/controller/BuildToken.php b/application/api/controller/BuildToken.php index 6a9971d9bb116e448b6ba9382557d89d92157065..a2f89966e2d1c3db9bd8b3cc446fe211e8a04197 100644 --- a/application/api/controller/BuildToken.php +++ b/application/api/controller/BuildToken.php @@ -7,7 +7,6 @@ namespace app\api\controller; - use app\model\AdminApp; use app\util\ReturnCode; use app\util\Strs; @@ -85,5 +84,4 @@ class BuildToken extends Base { return md5($preStr); } - } diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php index 98c52a36e41d630ce0c3987541d760d0d1a7ccee..af3cfc0deee0396fbce7d3f317440805394bde73 100644 --- a/application/api/controller/Index.php +++ b/application/api/controller/Index.php @@ -2,20 +2,20 @@ namespace app\api\controller; - use think\facade\App; class Index extends Base { + public function index() { $this->debug([ 'TpVersion' => App::version() ]); return $this->buildSuccess([ - 'Product' => config('apiadmin.APP_NAME'), - 'Version' => config('apiadmin.APP_VERSION'), - 'Company' => config('apiadmin.COMPANY_NAME'), - 'ToYou' => "I'm glad to meet you(终于等到你!)" + 'Product' => config('apiadmin.APP_NAME'), + 'Version' => config('apiadmin.APP_VERSION'), + 'Company' => config('apiadmin.COMPANY_NAME'), + 'ToYou' => "I'm glad to meet you(终于等到你!)" ]); } } diff --git a/application/api/controller/Miss.php b/application/api/controller/Miss.php index 36f75fcb731279f7cb6fe2aba8929fc08e802293..c279faf5af19b836fad80326bd04d220dc8f9929 100644 --- a/application/api/controller/Miss.php +++ b/application/api/controller/Miss.php @@ -2,22 +2,22 @@ namespace app\api\controller; - use app\util\StrRandom; use think\facade\App; class Miss extends Base { + public function index() { $this->debug([ 'TpVersion' => App::version(), - 'Float' => StrRandom::randomPhone() + 'Float' => StrRandom::randomPhone() ]); return $this->buildSuccess([ - 'Product' => config('apiadmin.APP_NAME'), - 'Version' => config('apiadmin.APP_VERSION'), - 'Company' => config('apiadmin.COMPANY_NAME'), - 'ToYou' => "I'm glad to meet you(终于等到你!)" + 'Product' => config('apiadmin.APP_NAME'), + 'Version' => config('apiadmin.APP_VERSION'), + 'Company' => config('apiadmin.COMPANY_NAME'), + 'ToYou' => "I'm glad to meet you(终于等到你!)" ]); } } diff --git a/application/command/Install.php b/application/command/Install.php index 0b78a359f10f0fc74f6950721064f5636efb08ae..f354d5920dba1e457b0c6b29511597d16ad22b4b 100644 --- a/application/command/Install.php +++ b/application/command/Install.php @@ -20,7 +20,7 @@ class Install extends Command { } /** - * php think apiadmin:install --db mysql://root:123456@127.0.0.1:3306/apiadmin#utf8 + * php think apiadmin:install --db mysql://root:123456@127.0.0.1:3306/apiadmin#utf8mb4 * @param Input $input * @param Output $output * @return int|void|null diff --git a/application/http/middleware/AdminLog.php b/application/http/middleware/AdminLog.php index f55967ab5314325db8669114c1be932ecef6b5bd..0e6959836f87f314db0f71d9ec81446a6f99115f 100644 --- a/application/http/middleware/AdminLog.php +++ b/application/http/middleware/AdminLog.php @@ -40,5 +40,4 @@ class AdminLog { return $next($request); } - } diff --git a/application/http/middleware/AdminPermission.php b/application/http/middleware/AdminPermission.php index ceee7288b8648a222d88e59bda9827a32a83f955..c41b04092c00ee6a3245d4dde2a81331d7836824 100644 --- a/application/http/middleware/AdminPermission.php +++ b/application/http/middleware/AdminPermission.php @@ -53,7 +53,6 @@ class AdminPermission { } else { return true; } - } /** @@ -93,5 +92,4 @@ class AdminPermission { return []; } } - } diff --git a/application/http/middleware/AdminResponse.php b/application/http/middleware/AdminResponse.php index 3f79fc5101643da29cfca6033fc3003f468ff74d..422b4a5dc052a28544738bb8d00429069b2cd075 100644 --- a/application/http/middleware/AdminResponse.php +++ b/application/http/middleware/AdminResponse.php @@ -5,6 +5,7 @@ namespace app\http\middleware; use think\facade\Config; class AdminResponse { + public function handle($request, \Closure $next) { return $next($request)->header(Config::get('apiadmin.CROSS_DOMAIN')); } diff --git a/application/http/middleware/ApiResponse.php b/application/http/middleware/ApiResponse.php index 2431f2858e5e1d1ad4e388d2f974c4a3d5ee9895..49a108ba541fdc2095c6714816e9f220da61fb83 100644 --- a/application/http/middleware/ApiResponse.php +++ b/application/http/middleware/ApiResponse.php @@ -5,6 +5,7 @@ namespace app\http\middleware; use think\facade\Config; class ApiResponse { + public function handle($request, \Closure $next) { return $next($request)->header(Config::get('apiadmin.CROSS_DOMAIN')); } diff --git a/application/http/middleware/RequestFilter.php b/application/http/middleware/RequestFilter.php index 666fbc497eeac0768ef02c900513116cb15f3f1f..6f148edd306c4066e17000f0400067c5b65052fa 100644 --- a/application/http/middleware/RequestFilter.php +++ b/application/http/middleware/RequestFilter.php @@ -8,7 +8,6 @@ use app\util\ReturnCode; use think\facade\Cache; use think\facade\Validate; - class RequestFilter { /** diff --git a/application/install/.gitignore b/application/install/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8d96e5b8604de9806453f770da6a70b60e89af05 --- /dev/null +++ b/application/install/.gitignore @@ -0,0 +1,2 @@ +!.gitignore +lock.ini diff --git a/application/model/AdminApp.php b/application/model/AdminApp.php index 58957486d60945df9908c1a9d850a9dfc145f441..2aba301e2f5f652a4fe8b87ecccf9adcdb3a5c5e 100644 --- a/application/model/AdminApp.php +++ b/application/model/AdminApp.php @@ -2,7 +2,6 @@ namespace app\model; - class AdminApp extends Base { } diff --git a/application/model/AdminAppGroup.php b/application/model/AdminAppGroup.php index 1d3a1eaba775507676fb7cdc898b7caa5efade8c..8df356dfcebc56f9e083b65b36489d336545457f 100644 --- a/application/model/AdminAppGroup.php +++ b/application/model/AdminAppGroup.php @@ -7,7 +7,6 @@ namespace app\model; - class AdminAppGroup extends Base { } diff --git a/application/model/AdminAuthGroup.php b/application/model/AdminAuthGroup.php index a881b9dc20e9acbea165d29eec7fb26be04cde87..eb000680838d3b839e0bd69e42edd11d545fe38c 100644 --- a/application/model/AdminAuthGroup.php +++ b/application/model/AdminAuthGroup.php @@ -7,11 +7,9 @@ namespace app\model; - class AdminAuthGroup extends Base { public function rules() { return $this->hasMany('AdminAuthRule', 'group_id', 'id'); } - } diff --git a/application/model/AdminAuthGroupAccess.php b/application/model/AdminAuthGroupAccess.php index 94848fd2a1c8568b4187a649f58ab891b4bffd3b..c0027b191e4eee009e7c4dcb66750f42f2426106 100644 --- a/application/model/AdminAuthGroupAccess.php +++ b/application/model/AdminAuthGroupAccess.php @@ -7,7 +7,6 @@ namespace app\model; - class AdminAuthGroupAccess extends Base { } diff --git a/application/model/AdminAuthRule.php b/application/model/AdminAuthRule.php index 81220aeab9e41157640bc1a2f99d7701e0d775ca..bdf846d03220e305a5f4072717b24678e11a89ce 100644 --- a/application/model/AdminAuthRule.php +++ b/application/model/AdminAuthRule.php @@ -7,7 +7,6 @@ namespace app\model; - class AdminAuthRule extends Base { } diff --git a/application/model/AdminGroup.php b/application/model/AdminGroup.php index 2dbc46fc0067b64fc786a9ce42afe324d3a495bf..dfe9b47d3850e9589661aa55b57dfb50b5cf9a95 100644 --- a/application/model/AdminGroup.php +++ b/application/model/AdminGroup.php @@ -7,7 +7,7 @@ namespace app\model; - class AdminGroup extends Base { + protected $autoWriteTimestamp = true; } diff --git a/application/model/AdminMenu.php b/application/model/AdminMenu.php index 8436936ecd70518a499b6f14ca01ca2adfcf7e1a..3e4e2800cbb6662a6393370bf13a2d22086e01d7 100644 --- a/application/model/AdminMenu.php +++ b/application/model/AdminMenu.php @@ -2,7 +2,6 @@ namespace app\model; - class AdminMenu extends Base { } diff --git a/application/model/AdminUser.php b/application/model/AdminUser.php index 483e9cb884a8d271548028e8b15e02967d7218c1..bd9234e69b09d0fe425c077947f23fcb27d06cf4 100644 --- a/application/model/AdminUser.php +++ b/application/model/AdminUser.php @@ -6,12 +6,11 @@ namespace app\model; - class AdminUser extends Base { + protected $autoWriteTimestamp = true; public function userData() { return $this->hasOne('AdminUserData', 'uid', 'id'); } - } diff --git a/application/model/AdminUserAction.php b/application/model/AdminUserAction.php index 5dc193c83fb4ace72717a277b4e302e7b57b4964..82daf69a2bc6523efc57c4c2cc6601cec20149bd 100644 --- a/application/model/AdminUserAction.php +++ b/application/model/AdminUserAction.php @@ -7,7 +7,6 @@ namespace app\model; - class AdminUserAction extends Base { } diff --git a/application/model/AdminUserData.php b/application/model/AdminUserData.php index 31a02c9ad7651fe26744351b30ed9e0bc989a769..221767f42293df85663f970f5be85e9a7bda5e7f 100644 --- a/application/model/AdminUserData.php +++ b/application/model/AdminUserData.php @@ -6,7 +6,6 @@ namespace app\model; - class AdminUserData extends Base { } diff --git a/application/model/Base.php b/application/model/Base.php index f8c0a6d91568edd3c96e6a67f9663b8d4ed0a69a..45ef387ffe3fedc0ec7a52f7266ebb1cf270e37e 100644 --- a/application/model/Base.php +++ b/application/model/Base.php @@ -7,7 +7,6 @@ namespace app\model; - use think\Model; class Base extends Model { diff --git a/application/util/ApiLogTool.php b/application/util/ApiLogTool.php index a7af39e2b3938eaeaca4b2aa48bd40a5fe9f04bf..dab0fe5714da7ab80819fe424305cd297c71b5c7 100644 --- a/application/util/ApiLogTool.php +++ b/application/util/ApiLogTool.php @@ -6,7 +6,6 @@ namespace app\util; - use think\facade\Env; class ApiLogTool { @@ -95,6 +94,4 @@ class ApiLogTool { @fwrite($handle, date('Y-m-d H:i:s') . "\t" . $log . "\r\n"); @fclose($handle); } - - } diff --git a/application/util/BuildName.php b/application/util/BuildName.php index ddba1ca663ad58de3451246f95d61167f6473934..c44ec60b41c0f59070b41a1c79fe65662b468381 100644 --- a/application/util/BuildName.php +++ b/application/util/BuildName.php @@ -7,8 +7,8 @@ namespace app\util; - class BuildName { + private $arrXing, $numbXing; private $arrMing, $numbMing; @@ -66,7 +66,6 @@ class BuildName { $this->numbMing = count($this->arrMing); } - // 获取姓 private function getXing() { // mt_rand() 比rand()方法快四倍,而且生成的随机数比rand()生成的伪随机数无规律。 @@ -79,7 +78,6 @@ class BuildName { return $this->arrMing[mt_rand(0, $this->numbMing - 1)]; } - // 获取名字 public function getName($type = 2) { switch ($type) { diff --git a/application/util/DataType.php b/application/util/DataType.php index e558302a633debf944cb951a217a6fc31482db4a..36938afa401a5135e2cf333ab2126c607ef6e387 100644 --- a/application/util/DataType.php +++ b/application/util/DataType.php @@ -8,7 +8,6 @@ namespace app\util; - class DataType { const TYPE_INTEGER = 1; @@ -20,5 +19,4 @@ class DataType { const TYPE_ENUM = 7; const TYPE_MOBILE = 8; const TYPE_OBJECT = 9; - } diff --git a/application/util/MockConf.php b/application/util/MockConf.php index d2364bc2a64dfa6913eca909e53c395c184031a1..3a09aa46445398160ac442836ec102ea2cdb433f 100644 --- a/application/util/MockConf.php +++ b/application/util/MockConf.php @@ -7,7 +7,6 @@ namespace app\util; - class MockConf { public function mockToApiAdmin() { @@ -17,5 +16,4 @@ class MockConf { public function apiAdminToMock() { } - } diff --git a/application/util/ReturnCode.php b/application/util/ReturnCode.php index 781dddaa1026aef9dcf8a3fc104e650c74dd86d3..f8ac0d76bf46d205e037791e46c460aba0ba15ce 100644 --- a/application/util/ReturnCode.php +++ b/application/util/ReturnCode.php @@ -41,9 +41,8 @@ class ReturnCode { const UNKNOWN = -998; const EXCEPTION = -999; - static public function getConstants() { + public static function getConstants() { $oClass = new \ReflectionClass(__CLASS__); return $oClass->getConstants(); } - -} \ No newline at end of file +} diff --git a/application/util/StrRandom.php b/application/util/StrRandom.php index 97c1d71dfc70cd3cb0e244f98e7105167ea93dc5..006834defda0fe7b2d8182b128300e2df0b4aafc 100644 --- a/application/util/StrRandom.php +++ b/application/util/StrRandom.php @@ -7,7 +7,6 @@ namespace app\util; - class StrRandom { /** @@ -182,5 +181,4 @@ class StrRandom { return $prefixArr[0] . '0000' . self::randomDate('Ymd') . Strs::randString(3, 1) . $suffixArr[0]; } - } diff --git a/application/util/Strs.php b/application/util/Strs.php index 46b600cbbe0d5a9e245ff5f6c7a2cf24f237a808..6bae4c41e992903d5e6aa9f7395a0cc0ff6ded16 100644 --- a/application/util/Strs.php +++ b/application/util/Strs.php @@ -8,6 +8,7 @@ // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- + namespace app\util; class Strs { @@ -17,7 +18,7 @@ class Strs { * @access public * @return string */ - static public function uuid() { + public static function uuid() { $charId = md5(uniqid(mt_rand(), true)); $hyphen = chr(45); $uuid = chr(123) @@ -35,7 +36,7 @@ class Strs { * 生成Guid主键 * @return Boolean */ - static public function keyGen() { + public static function keyGen() { return str_replace('-', '', substr(self::uuid(), 1, -1)); } @@ -44,7 +45,7 @@ class Strs { * @param string $string 字符串 * @return Boolean */ - static public function isUtf8($string) { + public static function isUtf8($string) { $len = strlen($string); for ($i = 0; $i < $len; $i++) { $c = ord($string[$i]); @@ -79,7 +80,7 @@ class Strs { * @param bool $suffix 截断显示字符 * @return string */ - static public function mSubStr($str, $start = 0, $length, $charset = "utf-8", $suffix = true) { + public static function mSubStr($str, $start = 0, $length, $charset = "utf-8", $suffix = true) { if (function_exists("mb_substr")) $slice = mb_substr($str, $start, $length, $charset); elseif (function_exists('iconv_substr')) { @@ -105,7 +106,7 @@ class Strs { * @param string $addChars 额外字符 * @return string */ - static public function randString($len = 6, $type = '', $addChars = '') { + public static function randString($len = 6, $type = '', $addChars = '') { $str = ''; switch ($type) { case 0: @@ -152,7 +153,7 @@ class Strs { * 0 字母 1 数字 其它 混合 * @return string */ - static public function buildCountRand($number, $length = 4, $mode = 1) { + public static function buildCountRand($number, $length = 4, $mode = 1) { if ($mode == 1 && $length < strlen($number)) { //不足以生成一定数量的不重复数字 return false; @@ -182,7 +183,7 @@ class Strs { * @param integer $number 生成数量 * @return string | array */ - static public function buildFormatRand($format, $number = 1) { + public static function buildFormatRand($format, $number = 1) { $str = array(); $length = strlen($format); for ($j = 0; $j < $number; $j++) { @@ -216,12 +217,12 @@ class Strs { * @param integer $max 最大值 * @return string */ - static public function randNumber($min, $max) { + public static function randNumber($min, $max) { return sprintf("%0" . strlen($max) . "d", mt_rand($min, $max)); } // 自动转换字符集 支持数组转换 - static public function autoCharset($string, $from = 'gbk', $to = 'utf-8') { + public static function autoCharset($string, $from = 'gbk', $to = 'utf-8') { $from = strtoupper($from) == 'UTF8' ? 'utf-8' : $from; $to = strtoupper($to) == 'UTF8' ? 'utf-8' : $to; if (strtoupper($from) === strtoupper($to) || empty($string) || (is_scalar($string) && !is_string($string))) { @@ -249,4 +250,4 @@ class Strs { return $string; } } -} \ No newline at end of file +} diff --git a/application/util/Tools.php b/application/util/Tools.php index e91ac0ce6566681c010f24c8d3577e47be6ce03a..82f923b6b0fe90cdb6b69fe2f6742baa29bca89f 100644 --- a/application/util/Tools.php +++ b/application/util/Tools.php @@ -7,7 +7,6 @@ namespace app\util; - class Tools { public static function getDate($timestamp) { diff --git a/application/wiki/controller/Api.php b/application/wiki/controller/Api.php index 95ba5c70680b5eaf6046ffa82636ab488abd7055..45e2048f49bb5cd674192ae1b1b8307f3cd360b2 100644 --- a/application/wiki/controller/Api.php +++ b/application/wiki/controller/Api.php @@ -6,7 +6,6 @@ namespace app\wiki\controller; - use app\model\AdminApp; use app\model\AdminFields; use app\model\AdminGroup; @@ -179,5 +178,4 @@ class Api extends Base { return $this->buildSuccess([], '登出成功'); } - } diff --git a/application/wiki/controller/Base.php b/application/wiki/controller/Base.php index 6a4e5b7ef5424ba6571feb2a6ea10337b7a93c7f..7ae5ad78366d892f992a8d55b813ec8b3244ab3a 100644 --- a/application/wiki/controller/Base.php +++ b/application/wiki/controller/Base.php @@ -7,7 +7,6 @@ namespace app\wiki\controller; - use app\util\ReturnCode; use think\Controller; @@ -39,5 +38,4 @@ class Base extends Controller { return $return; } - } diff --git a/route/route.php b/route/route.php index 7426dd75a908953299ef6a7ad7bd2fb40ad5c7d8..ec2137ba6dc49eae655d398a68147da4b120ee48 100644 --- a/route/route.php +++ b/route/route.php @@ -11,7 +11,6 @@ use think\facade\Route; - Route::group('admin', function() { Route::rule( 'Login/index', 'admin/Login/index', 'post' @@ -290,4 +289,3 @@ Route::group('admin', function() { //MISS路由定义 Route::miss('admin/Miss/index'); })->middleware('AdminResponse'); -