modified 初步完成登录接口

This commit is contained in:
zhaoxiang 2019-05-15 15:37:05 +08:00
parent 070b74850b
commit f9af5bea1b
3 changed files with 259 additions and 19 deletions

View File

@ -43,18 +43,18 @@ class Login extends Base {
$userData = AdminUserData::get(['uid' => $userInfo['id']]); $userData = AdminUserData::get(['uid' => $userInfo['id']]);
$data = []; $data = [];
if ($userData) { if ($userData) {
$userData->loginTimes ++; $userData->login_times ++;
$userData->lastLoginIp = $this->request->ip(1); $userData->last_login_ip = $this->request->ip(1);
$userData->lastLoginTime = time(); $userData->last_login_time = time();
$return['headImg'] = $userData['headImg']; $return['head_img'] = $userData['head_img'];
$userData->save(); $userData->save();
} else { } else {
$data['loginTimes'] = 1; $data['login_times'] = 1;
$data['uid'] = $userInfo['id']; $data['uid'] = $userInfo['id'];
$data['lastLoginIp'] = $this->request->ip(1); $data['last_login_ip'] = $this->request->ip(1);
$data['lastLoginTime'] = time(); $data['last_login_time'] = time();
$data['headImg'] = ''; $data['head_img'] = '';
$return['headImg'] = ''; $return['head_img'] = '';
AdminUserData::create($data); AdminUserData::create($data);
} }
} else { } else {
@ -75,8 +75,8 @@ class Login extends Base {
$return['access'] = array_values(array_filter(array_column($access, 'url'))); $return['access'] = array_values(array_filter(array_column($access, 'url')));
} else { } else {
$groups = AdminAuthGroupAccess::get(['uid' => $userInfo['id']]); $groups = AdminAuthGroupAccess::get(['uid' => $userInfo['id']]);
if (isset($groups) || $groups->groupId) { if (isset($groups) && $groups->group_id) {
$access = (new AdminAuthRule())->whereIn('groupId', $groups->groupId)->select(); $access = (new AdminAuthRule())->whereIn('group_id', $groups->group_id)->select();
$access = Tools::buildArrFromObj($access); $access = Tools::buildArrFromObj($access);
$return['access'] = array_values(array_unique(array_column($access, 'url'))); $return['access'] = array_values(array_unique(array_column($access, 'url')));
} }

View File

@ -29,7 +29,7 @@ return [
// 注册的根命名空间 // 注册的根命名空间
'root_namespace' => [], 'root_namespace' => [],
// 默认输出类型 // 默认输出类型
'default_return_type' => 'html', 'default_return_type' => 'json',
// 默认AJAX 数据返回格式,可选json xml ... // 默认AJAX 数据返回格式,可选json xml ...
'default_ajax_return' => 'json', 'default_ajax_return' => 'json',
// 默认JSONP格式返回的处理方法 // 默认JSONP格式返回的处理方法

View File

@ -9,12 +9,252 @@
// | Author: liu21st <liu21st@gmail.com> // | Author: liu21st <liu21st@gmail.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
Route::get('think', function () { use think\facade\Route;
return 'hello,ThinkPHP5!';
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 [
];