ComposerUpdate

This commit is contained in:
Anyon 2019-11-28 16:44:26 +08:00
parent 7fb9287203
commit 8501669f50
11 changed files with 26 additions and 33 deletions

View File

@ -16,7 +16,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use library\Controller; use library\Controller;
use library\service\AuthService; use library\service\AdminService;
use think\Db; use think\Db;
/** /**
@ -62,7 +62,7 @@ class Auth extends Controller
$action = strtolower(input('action', '')); $action = strtolower(input('action', ''));
if ($action === 'get') { if ($action === 'get') {
$checkeds = Db::name('SystemAuthNode')->where($map)->column('node'); $checkeds = Db::name('SystemAuthNode')->where($map)->column('node');
$this->success('获取权限节点成功!', AuthService::instance()->getTree($checkeds)); $this->success('获取权限节点成功!', AdminService::instance()->getTree($checkeds));
} elseif ($action === 'save') { } elseif ($action === 'save') {
list($post, $data) = [$this->request->post(), []]; list($post, $data) = [$this->request->post(), []];
foreach (isset($post['nodes']) ? $post['nodes'] : [] as $node) { foreach (isset($post['nodes']) ? $post['nodes'] : [] as $node) {
@ -70,7 +70,7 @@ class Auth extends Controller
} }
Db::name('SystemAuthNode')->where($map)->delete(); Db::name('SystemAuthNode')->where($map)->delete();
Db::name('SystemAuthNode')->insertAll($data); Db::name('SystemAuthNode')->insertAll($data);
AuthService::instance()->apply(true); AdminService::instance()->apply(true);
$this->success('权限授权更新成功!', 'javascript:history.back()'); $this->success('权限授权更新成功!', 'javascript:history.back()');
} else { } else {
$this->title = '权限配置节点'; $this->title = '权限配置节点';
@ -115,7 +115,7 @@ class Auth extends Controller
public function refresh() public function refresh()
{ {
try { try {
AuthService::instance()->apply(true); AdminService::instance()->apply(true);
$this->success('刷新系统授权成功!'); $this->success('刷新系统授权成功!');
} catch (\think\exception\HttpResponseException $exception) { } catch (\think\exception\HttpResponseException $exception) {
throw $exception; throw $exception;

View File

@ -16,7 +16,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use library\Controller; use library\Controller;
use library\service\AuthService; use library\service\AdminService;
use library\service\MenuService; use library\service\MenuService;
use library\tools\Data; use library\tools\Data;
use think\Console; use think\Console;
@ -41,7 +41,7 @@ class Index extends Controller
public function index() public function index()
{ {
$this->title = '系统管理后台'; $this->title = '系统管理后台';
$auth = AuthService::instance()->apply(true); $auth = AdminService::instance()->apply(true);
$this->menus = MenuService::instance()->getTree(); $this->menus = MenuService::instance()->getTree();
if (empty($this->menus) && !$auth->isLogin()) { if (empty($this->menus) && !$auth->isLogin()) {
$this->redirect('@admin/login'); $this->redirect('@admin/login');
@ -76,7 +76,7 @@ class Index extends Controller
if (intval($id) !== intval(session('user.id'))) { if (intval($id) !== intval(session('user.id'))) {
$this->error('只能修改当前用户的密码!'); $this->error('只能修改当前用户的密码!');
} }
if (!AuthService::instance()->isLogin()) { if (!AdminService::instance()->isLogin()) {
$this->error('需要登录才能操作哦!'); $this->error('需要登录才能操作哦!');
} }
if ($this->request->isGet()) { if ($this->request->isGet()) {
@ -122,7 +122,7 @@ class Index extends Controller
*/ */
public function info($id = 0) public function info($id = 0)
{ {
if (!AuthService::instance()->isLogin()) { if (!AdminService::instance()->isLogin()) {
$this->error('需要登录才能操作哦!'); $this->error('需要登录才能操作哦!');
} }
$this->applyCsrfToken(); $this->applyCsrfToken();

View File

@ -16,7 +16,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use library\Controller; use library\Controller;
use library\service\AuthService; use library\service\AdminService;
use library\service\CaptchaService; use library\service\CaptchaService;
use library\service\SystemService; use library\service\SystemService;
use think\Db; use think\Db;
@ -41,7 +41,7 @@ class Login extends Controller
public function index() public function index()
{ {
if (Request::isGet()) { if (Request::isGet()) {
if (AuthService::instance()->isLogin()) { if (AdminService::instance()->isLogin()) {
$this->redirect('@admin'); $this->redirect('@admin');
} else { } else {
$this->title = '系统登录'; $this->title = '系统登录';
@ -77,7 +77,7 @@ class Login extends Controller
]); ]);
session('user', $user); session('user', $user);
session('loginskey', null); session('loginskey', null);
AuthService::instance()->apply(true); AdminService::instance()->apply(true);
sysoplog('系统管理', '用户登录系统成功'); sysoplog('系统管理', '用户登录系统成功');
$this->success('登录成功', url('@admin')); $this->success('登录成功', url('@admin'));
} }

View File

@ -14,7 +14,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
use library\File; use library\File;
use library\service\AuthService; use library\service\AdminService;
use library\service\CaptchaService; use library\service\CaptchaService;
use library\service\SystemService; use library\service\SystemService;
use think\Db; use think\Db;
@ -31,7 +31,7 @@ if (!function_exists('auth')) {
*/ */
function auth($node) function auth($node)
{ {
return AuthService::instance()->check($node); return AdminService::instance()->check($node);
} }
} }
@ -141,9 +141,9 @@ if (!function_exists('base64_image')) {
// 访问权限检查中间键 // 访问权限检查中间键
Middleware::add(function (Request $request, \Closure $next) { Middleware::add(function (Request $request, \Closure $next) {
if (AuthService::instance()->check()) { if (AdminService::instance()->check()) {
return $next($request); return $next($request);
} elseif (AuthService::instance()->isLogin()) { } elseif (AdminService::instance()->isLogin()) {
return json(['code' => 0, 'msg' => '抱歉,没有访问该操作的权限!']); return json(['code' => 0, 'msg' => '抱歉,没有访问该操作的权限!']);
} else { } else {
return json(['code' => 0, 'msg' => '抱歉,需要登录获取访问权限!', 'url' => url('@admin/login')]); return json(['code' => 0, 'msg' => '抱歉,需要登录获取访问权限!', 'url' => url('@admin/login')]);

View File

@ -215,7 +215,7 @@ return array(
'library\\queue\\StateQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StateQueue.php', 'library\\queue\\StateQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StateQueue.php',
'library\\queue\\StopQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StopQueue.php', 'library\\queue\\StopQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StopQueue.php',
'library\\queue\\WorkQueue' => $vendorDir . '/zoujingli/think-library/src/queue/WorkQueue.php', 'library\\queue\\WorkQueue' => $vendorDir . '/zoujingli/think-library/src/queue/WorkQueue.php',
'library\\service\\AuthService' => $vendorDir . '/zoujingli/think-library/src/service/AuthService.php', 'library\\service\\AdminService' => $vendorDir . '/zoujingli/think-library/src/service/AdminService.php',
'library\\service\\CaptchaService' => $vendorDir . '/zoujingli/think-library/src/service/CaptchaService.php', 'library\\service\\CaptchaService' => $vendorDir . '/zoujingli/think-library/src/service/CaptchaService.php',
'library\\service\\MenuService' => $vendorDir . '/zoujingli/think-library/src/service/MenuService.php', 'library\\service\\MenuService' => $vendorDir . '/zoujingli/think-library/src/service/MenuService.php',
'library\\service\\NodeService' => $vendorDir . '/zoujingli/think-library/src/service/NodeService.php', 'library\\service\\NodeService' => $vendorDir . '/zoujingli/think-library/src/service/NodeService.php',

View File

@ -308,7 +308,7 @@ class ComposerStaticInit0ac7cd5b2cda0031cee9c92b2dc93c50
'library\\queue\\StateQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StateQueue.php', 'library\\queue\\StateQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StateQueue.php',
'library\\queue\\StopQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StopQueue.php', 'library\\queue\\StopQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StopQueue.php',
'library\\queue\\WorkQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/WorkQueue.php', 'library\\queue\\WorkQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/WorkQueue.php',
'library\\service\\AuthService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/AuthService.php', 'library\\service\\AdminService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/AdminService.php',
'library\\service\\CaptchaService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/CaptchaService.php', 'library\\service\\CaptchaService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/CaptchaService.php',
'library\\service\\MenuService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/MenuService.php', 'library\\service\\MenuService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/MenuService.php',
'library\\service\\NodeService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/NodeService.php', 'library\\service\\NodeService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/NodeService.php',

View File

@ -401,12 +401,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "1881f6a468e2c1e4eff5f18f4aa7aafd2752c196" "reference": "9b520cd35b4c7e9da6b928def3c5ec779e67bc0f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1881f6a468e2c1e4eff5f18f4aa7aafd2752c196", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/9b520cd35b4c7e9da6b928def3c5ec779e67bc0f",
"reference": "1881f6a468e2c1e4eff5f18f4aa7aafd2752c196", "reference": "9b520cd35b4c7e9da6b928def3c5ec779e67bc0f",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -426,7 +426,7 @@
"qiniu/php-sdk": "^7.2", "qiniu/php-sdk": "^7.2",
"topthink/framework": "5.1.*" "topthink/framework": "5.1.*"
}, },
"time": "2019-11-28T06:50:47+00:00", "time": "2019-11-28T08:41:39+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {

View File

@ -22,11 +22,5 @@
"psr-4": { "psr-4": {
"library\\": "src" "library\\": "src"
} }
},
"repositories": {
"packagist": {
"type": "composer",
"url": "https://mirrors.aliyun.com/composer"
}
} }
} }

View File

@ -24,7 +24,6 @@ use think\Db;
use think\db\Query; use think\db\Query;
use think\facade\Cache; use think\facade\Cache;
use think\facade\Middleware; use think\facade\Middleware;
use think\facade\Response;
use think\Request; use think\Request;
if (!function_exists('p')) { if (!function_exists('p')) {
@ -243,7 +242,7 @@ if (PHP_SAPI !== 'cli') {
$header['Access-Control-Expose-Headers'] = 'User-Token-Csrf'; $header['Access-Control-Expose-Headers'] = 'User-Token-Csrf';
} }
if ($request->isOptions()) { if ($request->isOptions()) {
return Response::create()->code(204)->header($header); return response()->code(204)->header($header);
} else { } else {
return $next($request)->header($header); return $next($request)->header($header);
} }

View File

@ -23,10 +23,10 @@ use think\Db;
/** /**
* 系统权限管理服务 * 系统权限管理服务
* Class AuthService * Class AdminService
* @package think\admin\service * @package think\admin\service
*/ */
class AuthService extends Service class AdminService extends Service
{ {
/** /**
@ -88,7 +88,7 @@ class AuthService extends Service
/** /**
* 初始化用户权限 * 初始化用户权限
* @param boolean $force 强刷权限 * @param boolean $force 强刷权限
* @return AuthService * @return AdminService
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException

View File

@ -75,7 +75,7 @@ class MenuService extends Service
else { else {
$node = join('/', array_slice(explode('/', preg_replace('/[\W]/', '/', $menu['url'])), 0, 3)); $node = join('/', array_slice(explode('/', preg_replace('/[\W]/', '/', $menu['url'])), 0, 3));
$menu['url'] = url($menu['url']) . (empty($menu['params']) ? '' : "?{$menu['params']}"); $menu['url'] = url($menu['url']) . (empty($menu['params']) ? '' : "?{$menu['params']}");
if (!AuthService::instance()->check($node)) unset($menus[$key]); if (!AdminService::instance()->check($node)) unset($menus[$key]);
} }
} }
return $menus; return $menus;