diff --git a/application/admin/controller/App.php b/application/admin/controller/App.php index 32a09b2..ae8f984 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 c8f6a7e..a7d7d64 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 cce7462..cfe9623 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 - ]; - } - } - (new AdminAuthRule())->saveAll($insertData); - } - - return $this->buildSuccess(); } + if ($rules) { + $insertData = []; + foreach ($rules as $value) { + if ($value) { + $insertData[] = [ + 'group_id' => $res->id, + 'url' => $value + ]; + } + } + (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 ee8996d..52f7cf6 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 fe51246..c9b6778 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 9bbf797..ed3c94a 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 64b39cf..320b1c4 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 be8e98f..b6f5e2b 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 9eac714..b7efe7e 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 784f73a..1418706 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 dd32528..3290130 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 ddddc43..bd175cd 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 97e1401..da95c49 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); - } 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(); } + $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(); } /** @@ -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 3cf4c5d..2708010 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 6a9971d..a2f8996 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 98c52a3..af3cfc0 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 36f75fc..c279faf 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 0b78a35..f354d59 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 f55967a..0e69598 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 ceee728..c41b040 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 3f79fc5..422b4a5 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 2431f28..49a108b 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 666fbc4..6f148ed 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 0000000..8d96e5b --- /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 5895748..2aba301 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 1d3a1ea..8df356d 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 a881b9d..eb00068 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 94848fd..c0027b1 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 81220ae..bdf846d 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 2dbc46f..dfe9b47 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 8436936..3e4e280 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 483e9cb..bd9234e 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 5dc193c..82daf69 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 31a02c9..221767f 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 f8c0a6d..45ef387 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 a7af39e..dab0fe5 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 ddba1ca..c44ec60 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 e558302..36938af 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 d2364bc..3a09aa4 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 781ddda..f8ac0d7 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 97c1d71..006834d 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 46b600c..6bae4c4 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 e91ac0c..82f923b 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 95ba5c7..45e2048 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 6a4e5b7..7ae5ad7 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 7426dd7..ec2137b 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'); -