diff --git a/application/admin/controller/Login.php b/application/admin/controller/Login.php index 76e4ca3..bcd582b 100644 --- a/application/admin/controller/Login.php +++ b/application/admin/controller/Login.php @@ -43,18 +43,18 @@ class Login extends Base { $userData = AdminUserData::get(['uid' => $userInfo['id']]); $data = []; if ($userData) { - $userData->loginTimes ++; - $userData->lastLoginIp = $this->request->ip(1); - $userData->lastLoginTime = time(); - $return['headImg'] = $userData['headImg']; + $userData->login_times ++; + $userData->last_login_ip = $this->request->ip(1); + $userData->last_login_time = time(); + $return['head_img'] = $userData['head_img']; $userData->save(); } else { - $data['loginTimes'] = 1; + $data['login_times'] = 1; $data['uid'] = $userInfo['id']; - $data['lastLoginIp'] = $this->request->ip(1); - $data['lastLoginTime'] = time(); - $data['headImg'] = ''; - $return['headImg'] = ''; + $data['last_login_ip'] = $this->request->ip(1); + $data['last_login_time'] = time(); + $data['head_img'] = ''; + $return['head_img'] = ''; AdminUserData::create($data); } } else { @@ -75,8 +75,8 @@ class Login extends Base { $return['access'] = array_values(array_filter(array_column($access, 'url'))); } else { $groups = AdminAuthGroupAccess::get(['uid' => $userInfo['id']]); - if (isset($groups) || $groups->groupId) { - $access = (new AdminAuthRule())->whereIn('groupId', $groups->groupId)->select(); + if (isset($groups) && $groups->group_id) { + $access = (new AdminAuthRule())->whereIn('group_id', $groups->group_id)->select(); $access = Tools::buildArrFromObj($access); $return['access'] = array_values(array_unique(array_column($access, 'url'))); } diff --git a/config/app.php b/config/app.php index 7316a4f..3653eeb 100644 --- a/config/app.php +++ b/config/app.php @@ -29,7 +29,7 @@ return [ // 注册的根命名空间 'root_namespace' => [], // 默认输出类型 - 'default_return_type' => 'html', + 'default_return_type' => 'json', // 默认AJAX 数据返回格式,可选json xml ... 'default_ajax_return' => 'json', // 默认JSONP格式返回的处理方法 diff --git a/route/route.php b/route/route.php index 6f479d3..ace76d5 100644 --- a/route/route.php +++ b/route/route.php @@ -9,12 +9,252 @@ // | Author: liu21st // +---------------------------------------------------------------------- -Route::get('think', function () { - return 'hello,ThinkPHP5!'; +use think\facade\Route; + +Route::rule('admin/Login/index','admin/Login/index','post'); +Route::rule('admin/Index/upload','admin/Index/upload','post'); +Route::rule('admin/Login/logout','admin/Login/logout','get'); + +Route::group('admin', function () { + //大部分控制器的路由都以分组的形式写到这里 + Route::group('Menu', [ + 'index' => [ + 'admin/Menu/index', + ['method' => 'get'] + ], + 'changeStatus' => [ + 'admin/Menu/changeStatus', + ['method' => 'get'] + ], + 'add' => [ + 'admin/Menu/add', + ['method' => 'post'] + ], + 'edit' => [ + 'admin/Menu/edit', + ['method' => 'post'] + ], + 'del' => [ + 'admin/Menu/del', + ['method' => 'get'] + ] + ]); + Route::group('User', [ + 'index' => [ + 'admin/User/index', + ['method' => 'get'] + ], + 'getUsers' => [ + 'admin/User/getUsers', + ['method' => 'get'] + ], + 'changeStatus' => [ + 'admin/User/changeStatus', + ['method' => 'get'] + ], + 'add' => [ + 'admin/User/add', + ['method' => 'post'] + ], + 'own' => [ + 'admin/User/own', + ['method' => 'post'] + ], + 'edit' => [ + 'admin/User/edit', + ['method' => 'post'] + ], + 'del' => [ + 'admin/User/del', + ['method' => 'get'] + ], + ]); + Route::group('Auth', [ + 'index' => [ + 'admin/Auth/index', + ['method' => 'get'] + ], + 'changeStatus' => [ + 'admin/Auth/changeStatus', + ['method' => 'get'] + ], + 'add' => [ + 'admin/Auth/add', + ['method' => 'post'] + ], + 'delMember' => [ + 'admin/Auth/delMember', + ['method' => 'get'] + ], + 'edit' => [ + 'admin/Auth/edit', + ['method' => 'post'] + ], + 'del' => [ + 'admin/Auth/del', + ['method' => 'get'] + ], + 'getGroups' => [ + 'admin/Auth/getGroups', + ['method' => 'get'] + ], + 'getRuleList' => [ + 'admin/Auth/getRuleList', + ['method' => 'get'] + ] + ]); + Route::group('App', [ + 'index' => [ + 'admin/App/index', + ['method' => 'get'] + ], + 'refreshAppSecret' => [ + 'admin/App/refreshAppSecret', + ['method' => 'get'] + ], + 'changeStatus' => [ + 'admin/App/changeStatus', + ['method' => 'get'] + ], + 'add' => [ + 'admin/App/add', + ['method' => 'post'] + ], + 'getAppInfo' => [ + 'admin/App/getAppInfo', + ['method' => 'get'] + ], + 'edit' => [ + 'admin/App/edit', + ['method' => 'post'] + ], + 'del' => [ + 'admin/App/del', + ['method' => 'get'] + ] + ]); + Route::group('InterfaceList', [ + 'index' => [ + 'admin/InterfaceList/index', + ['method' => 'get'] + ], + 'changeStatus' => [ + 'admin/InterfaceList/changeStatus', + ['method' => 'get'] + ], + 'add' => [ + 'admin/InterfaceList/add', + ['method' => 'post'] + ], + 'refresh' => [ + 'admin/InterfaceList/refresh', + ['method' => 'get'] + ], + 'edit' => [ + 'admin/InterfaceList/edit', + ['method' => 'post'] + ], + 'del' => [ + 'admin/InterfaceList/del', + ['method' => 'get'] + ], + 'getHash' => [ + 'admin/InterfaceList/getHash', + ['method' => 'get'] + ] + ]); + Route::group('Fields', [ + 'index' => [ + 'admin/Fields/index', + ['method' => 'get'] + ], + 'request' => [ + 'admin/Fields/request', + ['method' => 'get'] + ], + 'add' => [ + 'admin/Fields/add', + ['method' => 'post'] + ], + 'response' => [ + 'admin/Fields/response', + ['method' => 'get'] + ], + 'edit' => [ + 'admin/Fields/edit', + ['method' => 'post'] + ], + 'del' => [ + 'admin/Fields/del', + ['method' => 'get'] + ], + 'upload' => [ + 'admin/Fields/upload', + ['method' => 'post'] + ] + ]); + Route::group('InterfaceGroup', [ + 'index' => [ + 'admin/InterfaceGroup/index', + ['method' => 'get'] + ], + 'getAll' => [ + 'admin/InterfaceGroup/getAll', + ['method' => 'get'] + ], + 'add' => [ + 'admin/InterfaceGroup/add', + ['method' => 'post'] + ], + 'changeStatus' => [ + 'admin/InterfaceGroup/changeStatus', + ['method' => 'get'] + ], + 'edit' => [ + 'admin/InterfaceGroup/edit', + ['method' => 'post'] + ], + 'del' => [ + 'admin/InterfaceGroup/del', + ['method' => 'get'] + ] + ]); + Route::group('AppGroup', [ + 'index' => [ + 'admin/AppGroup/index', + ['method' => 'get'] + ], + 'getAll' => [ + 'admin/AppGroup/getAll', + ['method' => 'get'] + ], + 'add' => [ + 'admin/AppGroup/add', + ['method' => 'post'] + ], + 'changeStatus' => [ + 'admin/AppGroup/changeStatus', + ['method' => 'get'] + ], + 'edit' => [ + 'admin/AppGroup/edit', + ['method' => 'post'] + ], + 'del' => [ + 'admin/AppGroup/del', + ['method' => 'get'] + ] + ]); + Route::group('Log', [ + 'index' => [ + 'admin/Log/index', + ['method' => 'get'] + ], + 'del' => [ + 'admin/Log/del', + ['method' => 'get'] + ] + ]); + Route::miss('admin/Miss/index'); }); -Route::get('hello/:name', 'index/hello'); - -return [ - -];