time(), 'last_login_ip' => request()->ip(), 'update_time' => time(), ]; $res = $adminUserObj->updateById($adminUser['id'], $updateData); if (empty($res)) { throw new Exception('登陆失败'); // return show(config('status.error'), '登陆失败'); } // 记录session session(config('admin.session_admin'), $adminUser); return true; } /** * 通过用户名获取用户数据 * @param $username * @return array|bool|\think\Model|null * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public static function getAdminUserByUsername($username) { $adminUserObj = new AdminUserModel(); $adminUser = $adminUserObj->getAdminUserByUsername($username); if (empty($adminUser) || $adminUser->status != config('status.mysql.table_normal')) { return false; } $adminUser = $adminUser->toArray(); return $adminUser; } }