From 85f5f4e5523a9f001dbaec640746de41257530a2 Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 14 Jun 2019 18:53:04 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E5=90=8C=E6=AD=A5framework?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Auth.php | 6 +- application/admin/controller/Index.php | 10 +- application/admin/controller/Log.php | 86 --------- application/admin/controller/Login.php | 5 +- application/admin/controller/Menu.php | 4 +- application/admin/controller/Message.php | 20 +-- application/admin/controller/Node.php | 4 +- application/admin/controller/Queue.php | 11 +- application/admin/controller/User.php | 4 +- application/admin/controller/api/Message.php | 6 +- application/admin/controller/api/Plugs.php | 2 +- application/admin/queue/JobsBase.php | 122 ------------- application/admin/service/Auth.php | 176 ------------------- application/admin/service/Log.php | 55 ------ application/admin/service/Message.php | 72 -------- application/admin/service/Queue.php | 128 -------------- application/admin/sys.php | 36 ++-- application/admin/view/auth/index.html | 16 +- application/admin/view/config/file.html | 17 +- application/admin/view/config/info.html | 14 +- application/admin/view/index/main.html | 125 ++++++++++++- application/admin/view/log/index.html | 68 ------- application/admin/view/log/index_search.html | 56 ------ application/admin/view/menu/index.html | 18 +- application/admin/view/message/index.html | 18 +- application/admin/view/node/index.html | 2 +- application/admin/view/queue/index.html | 16 +- application/admin/view/user/index.html | 8 +- public/static/theme/css/console.css | 17 +- 29 files changed, 238 insertions(+), 884 deletions(-) delete mode 100644 application/admin/controller/Log.php delete mode 100644 application/admin/queue/JobsBase.php delete mode 100644 application/admin/service/Auth.php delete mode 100644 application/admin/service/Log.php delete mode 100644 application/admin/service/Message.php delete mode 100644 application/admin/service/Queue.php delete mode 100644 application/admin/view/log/index.html delete mode 100644 application/admin/view/log/index_search.html diff --git a/application/admin/controller/Auth.php b/application/admin/controller/Auth.php index ce21608a9..642229812 100644 --- a/application/admin/controller/Auth.php +++ b/application/admin/controller/Auth.php @@ -58,7 +58,7 @@ class Auth extends Controller $auth = $this->request->post('id', '0'); switch (strtolower($this->request->post('action'))) { case 'get': // 获取权限配置 - $nodes = \app\admin\service\Auth::get(); + $nodes = \app\admin\service\AuthService::get(); $checked = Db::name('SystemAuthNode')->where(['auth' => $auth])->column('node'); foreach ($nodes as &$node) $node['checked'] = in_array($node['node'], $checked); $data = $this->_apply_filter(\library\tools\Data::arr2tree($nodes, 'node', 'pnode', '_sub_')); @@ -131,7 +131,7 @@ class Auth extends Controller /** * 删除系统权限 */ - public function del() + public function remove() { $this->applyCsrfToken(); $this->_delete($this->table); @@ -143,7 +143,7 @@ class Auth extends Controller * @throws \think\Exception * @throws \think\exception\PDOException */ - protected function _del_delete_result($result) + protected function _remove_delete_result($result) { if ($result) { $where = ['auth' => $this->request->post('id')]; diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index c99593170..fdf8beb13 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -14,6 +14,7 @@ namespace app\admin\controller; +use app\admin\service\AuthService; use library\Controller; use library\tools\Data; use think\Console; @@ -37,7 +38,7 @@ class Index extends Controller public function index() { $this->title = '系统管理后台'; - $this->menus = \app\admin\service\Auth::getAuthMenu(); + $this->menus = AuthService::getAuthMenu(); if (empty($this->menus) && !session('user.id')) { $this->redirect('@admin/login'); } else { @@ -51,7 +52,6 @@ class Index extends Controller */ public function main() { - $this->title = '后台首页'; $this->think_ver = \think\App::VERSION; $this->mysql_ver = Db::query('select version() as ver')[0]['ver']; $this->fetch(); @@ -62,7 +62,7 @@ class Index extends Controller */ public function clearRuntime() { - if (!\app\admin\service\Auth::isLogin()) { + if (!AuthService::isLogin()) { $this->error('需要登录才能操作哦!'); } $this->list = [ @@ -82,7 +82,7 @@ class Index extends Controller */ public function buildOptimize() { - if (!\app\admin\service\Auth::isLogin()) { + if (!AuthService::isLogin()) { $this->error('需要登录才能操作哦!'); } $this->list = [ @@ -141,7 +141,7 @@ class Index extends Controller if (md5($data['oldpassword']) !== $user['password']) { $this->error('旧密码验证失败,请重新输入!'); } - $result = \app\admin\service\Auth::checkPassword($data['password']); + $result = AuthService::checkPassword($data['password']); if (empty($result['code'])) $this->error($result['msg']); if (Data::save('SystemUser', ['id' => $user['id'], 'password' => md5($data['password'])])) { $this->success('密码修改成功,下次请使用新密码登录!', ''); diff --git a/application/admin/controller/Log.php b/application/admin/controller/Log.php deleted file mode 100644 index 424a29a89..000000000 --- a/application/admin/controller/Log.php +++ /dev/null @@ -1,86 +0,0 @@ -title = '系统操作日志'; - $query = $this->_query($this->table)->like('action,node,content,username,geoip'); - $query->dateBetween('create_at')->order('id desc')->page(); - } - - /** - * 列表数据处理 - * @param array $data - * @throws \Exception - */ - protected function _index_page_filter(&$data) - { - $ip = new \Ip2Region(); - foreach ($data as &$vo) { - $result = $ip->btreeSearch($vo['geoip']); - $vo['isp'] = isset($result['region']) ? $result['region'] : ''; - $vo['isp'] = str_replace(['内网IP', '0', '|'], '', $vo['isp']); - } - } - - /** - * 清理系统日志 - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public function clear() - { - if (Db::name($this->table)->whereRaw('1=1')->delete() !== false) { - $this->success('日志清理成功!'); - } else { - $this->error('日志清理失败,请稍候再试!'); - } - } - - /** - * 删除系统日志 - */ - public function del() - { - $this->applyCsrfToken(); - $this->_delete($this->table); - } - -} \ No newline at end of file diff --git a/application/admin/controller/Login.php b/application/admin/controller/Login.php index 80db67121..afdf76900 100644 --- a/application/admin/controller/Login.php +++ b/application/admin/controller/Login.php @@ -14,6 +14,7 @@ namespace app\admin\controller; +use app\admin\service\AuthService; use library\Controller; use think\Db; @@ -38,7 +39,7 @@ class Login extends Controller */ protected function _index_get() { - if (\app\admin\service\Auth::isLogin()) { + if (AuthService::isLogin()) { $this->redirect('@admin'); } else { $this->loginskey = session('loginskey'); @@ -108,7 +109,7 @@ class Login extends Controller session('user', $user); session('loginskey', null); _syslog('系统管理', '用户登录系统成功'); - empty($user['authorize']) || \app\admin\service\Auth::applyNode(); + empty($user['authorize']) || AuthService::applyNode(); $this->success('登录成功,正在进入系统...', url('@admin')); } diff --git a/application/admin/controller/Menu.php b/application/admin/controller/Menu.php index 0d48782be..14ee3fa14 100644 --- a/application/admin/controller/Menu.php +++ b/application/admin/controller/Menu.php @@ -95,7 +95,7 @@ class Menu extends Controller // 选择自己的上级菜单 if (!isset($vo['pid']) && $this->request->get('pid', '0')) $vo['pid'] = $this->request->get('pid', '0'); // 读取系统功能节点 - $nodes = \app\admin\service\Auth::get(); + $nodes = \app\admin\service\AuthService::get(); foreach ($nodes as $key => $node) { if (empty($node['is_menu'])) unset($nodes[$key]); unset($nodes[$key]['pnode'], $nodes[$key]['is_login'], $nodes[$key]['is_menu'], $nodes[$key]['is_auth']); @@ -125,7 +125,7 @@ class Menu extends Controller /** * 删除系统菜单 */ - public function del() + public function remove() { $this->applyCsrfToken(); $this->_delete($this->table); diff --git a/application/admin/controller/Message.php b/application/admin/controller/Message.php index 0ee72caaf..6913ed5d8 100644 --- a/application/admin/controller/Message.php +++ b/application/admin/controller/Message.php @@ -48,19 +48,11 @@ class Message extends Controller /** * 设置消息状态 */ - public function state() + public function read() { $this->_save($this->table, ['read_state' => '1', 'read_at' => date('Y-m-d H:i:s')]); } - /** - * 删除系统消息 - */ - public function del() - { - $this->_delete($this->table); - } - /** * 清理所有消息 * @throws \think\Exception @@ -80,7 +72,7 @@ class Message extends Controller * @throws \think\Exception * @throws \think\exception\PDOException */ - public function onoff() + public function state() { sysconf('system_message_state', sysconf('system_message_state') ? 0 : 1); if (sysconf('system_message_state')) { @@ -90,4 +82,12 @@ class Message extends Controller } } + /** + * 删除系统消息 + */ + public function remove() + { + $this->_delete($this->table); + } + } \ No newline at end of file diff --git a/application/admin/controller/Node.php b/application/admin/controller/Node.php index 529299247..6dceab9d6 100644 --- a/application/admin/controller/Node.php +++ b/application/admin/controller/Node.php @@ -38,7 +38,7 @@ class Node extends Controller public function index() { $this->title = '系统节点管理'; - list($nodes, $groups) = [\app\admin\service\Auth::get(), []]; + list($nodes, $groups) = [\app\admin\service\AuthService::get(), []]; $this->nodes = Data::arr2table($nodes, 'node', 'pnode'); foreach ($this->nodes as $node) { $pnode = explode('/', $node['node'])[0]; @@ -57,7 +57,7 @@ class Node extends Controller */ public function clear() { - $nodes = array_unique(array_column(\app\admin\service\Auth::get(), 'node')); + $nodes = array_unique(array_column(\app\admin\service\AuthService::get(), 'node')); if (false !== Db::name($this->table)->whereNotIn('node', $nodes)->delete()) { $this->success('清理无效的节点配置成功!', ''); } else { diff --git a/application/admin/controller/Queue.php b/application/admin/controller/Queue.php index 8a5eacc5d..914a29ffb 100644 --- a/application/admin/controller/Queue.php +++ b/application/admin/controller/Queue.php @@ -42,10 +42,11 @@ class Queue extends Controller public function index() { $this->title = '消息任务管理'; - $this->uris = Db::name($this->table)->distinct(true)->column('uri'); $this->cmd = 'php ' . env('root_path') . 'think xtask:start'; $this->message = Console::call('xtask:state')->fetch(); - $this->_query($this->table)->equal('status,title,uri')->dateBetween('create_at,status_at')->order('id desc')->page(); + $this->uris = Db::name($this->table)->distinct(true)->column('uri'); + $query = $this->_query($this->table)->dateBetween('create_at,status_at'); + $query->equal('status,title,uri')->order('id desc')->page(); } /** @@ -58,7 +59,7 @@ class Queue extends Controller $info = Db::name($this->table)->where($where)->find(); if (empty($info)) $this->error('需要重置的任务获取异常!'); $data = isset($info['data']) ? json_decode($info['data'], true) : '[]'; - \app\admin\service\Queue::add($info['title'], $info['uri'], $info['later'], $data, $info['double'], $info['desc']); + \app\admin\service\QueueService::add($info['title'], $info['uri'], $info['later'], $data, $info['double'], $info['desc']); $this->success('任务重置成功!', url('@admin') . '#' . url('@admin/queue/index')); } catch (\think\exception\HttpResponseException $exception) { throw $exception; @@ -70,12 +71,12 @@ class Queue extends Controller /** * 删除消息任务 */ - public function del() + public function remove() { try { $isNot = false; foreach (explode(',', $this->request->post('id', '0')) as $id) { - if (!\app\admin\service\Queue::del($id)) $isNot = true; + if (!\app\admin\service\QueueService::del($id)) $isNot = true; } if (empty($isNot)) $this->_delete($this->table); $this->success($isNot ? '部分任务删除成功!' : '任务删除成功!'); diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index 1fe8ab150..8c526051e 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -96,7 +96,7 @@ class User extends Controller if ($post['password'] !== $post['repassword']) { $this->error('两次输入的密码不一致!'); } - $result = \app\admin\service\Auth::checkPassword($post['password']); + $result = \app\admin\service\AuthService::checkPassword($post['password']); if (empty($result['code'])) $this->error($result['msg']); $data = ['id' => $post['id'], 'password' => md5($post['password'])]; if (Data::save($this->table, $data, 'id')) { @@ -152,7 +152,7 @@ class User extends Controller /** * 删除系统用户 */ - public function del() + public function remove() { if (in_array('10000', explode(',', $this->request->post('id')))) { $this->error('系统超级账号禁止删除!'); diff --git a/application/admin/controller/api/Message.php b/application/admin/controller/api/Message.php index 7e68548bc..9e8bd9c2e 100644 --- a/application/admin/controller/api/Message.php +++ b/application/admin/controller/api/Message.php @@ -29,7 +29,7 @@ class Message extends Controller public function __construct() { parent::__construct(); - if (!\app\admin\service\Auth::isLogin()) { + if (!\app\admin\service\AuthService::isLogin()) { $this->error('访问授权失败,请重新登录授权再试!'); } } @@ -42,7 +42,7 @@ class Message extends Controller */ public function gets() { - $list = \app\admin\service\Message::gets(); + $list = \app\admin\service\MessageService::gets(); $this->success('获取系统消息成功!', $list); } @@ -54,7 +54,7 @@ class Message extends Controller public function set() { $code = $this->request->post('code'); - if (\app\admin\service\Message::set($code)) { + if (\app\admin\service\MessageService::set($code)) { $this->success('系统消息状态更新成功!'); } else { $this->error('系统消息状态更新失败,请稍候再试!'); diff --git a/application/admin/controller/api/Plugs.php b/application/admin/controller/api/Plugs.php index d6e9564ba..f29c599ca 100644 --- a/application/admin/controller/api/Plugs.php +++ b/application/admin/controller/api/Plugs.php @@ -32,7 +32,7 @@ class Plugs extends Controller public function __construct() { parent::__construct(); - if (!\app\admin\service\Auth::isLogin()) { + if (!\app\admin\service\AuthService::isLogin()) { $this->error('访问授权失败,请重新登录授权再试!'); } } diff --git a/application/admin/queue/JobsBase.php b/application/admin/queue/JobsBase.php deleted file mode 100644 index 5045c2caf..000000000 --- a/application/admin/queue/JobsBase.php +++ /dev/null @@ -1,122 +0,0 @@ -data = $data; - $this->output = new \think\console\Output(); - $this->id = isset($data['_job_id_']) ? $data['_job_id_'] : ''; - $this->title = isset($data['_job_title_']) ? $data['_job_title_'] : ''; - $this->output->newLine(); - $this->output->writeln(" system task {$this->id} execution start"); - $this->output->writeln('---------------------------------------------'); - Queue::status($this->id, self::STATUS_PROC, $this->statusDesc); - if ($this->execute()) { - $this->output->writeln('---------------------------------------------'); - $this->output->info(" successful"); - $this->status = self::STATUS_COMP; - } else { - $this->output->writeln('---------------------------------------------'); - $this->output->error(" failure"); - $this->status = self::STATUS_FAIL; - } - $job->delete(); - Queue::status($this->id, $this->status, $this->statusDesc); - $this->output->writeln('---------------------------------------------'); - $this->output->newLine(); - } - - /** - * 执行任务 - * @return boolean - */ - protected function execute() - { - return true; - } - -} \ No newline at end of file diff --git a/application/admin/service/Auth.php b/application/admin/service/Auth.php deleted file mode 100644 index a9c67a7d1..000000000 --- a/application/admin/service/Auth.php +++ /dev/null @@ -1,176 +0,0 @@ -column('node,is_menu,is_auth,is_login,title'); - foreach (Node::getMethodTreeNode(env('app_path')) as $thr => $title) { - foreach ($ignore as $str) if (stripos($thr, $str) === 0) continue 2; - $tmp = explode('/', $thr); - list($one, $two) = ["{$tmp[0]}", "{$tmp[0]}/{$tmp[1]}"]; - $nodes[$one] = array_merge(isset($alias[$one]) ? $alias[$one] : ['node' => $one, 'title' => '', 'is_menu' => 0, 'is_auth' => 0, 'is_login' => 0], ['pnode' => '']); - $nodes[$two] = array_merge(isset($alias[$two]) ? $alias[$two] : ['node' => $two, 'title' => isset($map[$two]) ? $map[$two] : '', 'is_menu' => 0, 'is_auth' => 0, 'is_login' => 0], ['pnode' => $one]); - $nodes[$thr] = array_merge(isset($alias[$thr]) ? $alias[$thr] : ['node' => $thr, 'title' => $title, 'is_menu' => 0, 'is_auth' => 0, 'is_login' => 0], ['pnode' => $two]); - } - foreach ($nodes as &$node) list($node['is_auth'], $node['is_menu'], $node['is_login']) = [intval($node['is_auth']), intval($node['is_menu']), empty($node['is_auth']) ? intval($node['is_login']) : 1]; - return $nodes; - } - - /** - * 检查用户节点权限 - * @param string $node 节点 - * @return boolean - */ - public static function checkAuthNode($node) - { - list($module, $controller, $action) = explode('/', str_replace(['?', '=', '&'], '/', "{$node}///")); - $current = Node::parseString("{$module}/{$controller}") . strtolower("/{$action}"); - // 后台入口无需要验证权限 - if (stripos($node, 'admin/index') === 0) return true; - // 超级管理员无需要验证权限 - if (session('user.username') === 'admin') return true; - // 未配置权限的节点默认放行 - if (!in_array($current, self::getAuthNode())) return true; - // 用户指定角色授权放行 - return in_array($current, (array)session('user.nodes')); - } - - /** - * 获取授权节点 - * @return array - */ - public static function getAuthNode() - { - $nodes = cache('need_access_node'); - if (empty($nodes)) { - $nodes = Db::name('SystemNode')->where(['is_auth' => '1'])->column('node'); - cache('need_access_node', $nodes); - } - return $nodes; - } - - /** - * 应用用户权限节点 - * @return boolean - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public static function applyNode() - { - cache('need_access_node', null); - if (($uid = session('user.id'))) session('user', Db::name('SystemUser')->where('id', $uid)->find()); - if (session('user.authorize') && ($ids = explode(',', session('user.authorize')))) { - $auths = Db::name('SystemAuth')->whereIn('id', $ids)->where('status', '1')->column('id'); - if (empty($auths)) return session('user.nodes', []); - return session('user.nodes', Db::name('SystemAuthNode')->whereIn('auth', $auths)->column('node')); - } - return false; - } - - /** - * 判断用户登录状态 - * @return boolean - */ - public static function isLogin() - { - return !!session('user'); - } - - /** - * 获取授权后的菜单 - * @return array - * @throws \ReflectionException - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public static function getAuthMenu() - { - self::applyNode(); - $list = Db::name('SystemMenu')->where('status', '1')->order('sort asc,id asc')->select(); - return self::buildMenuData(Data::arr2tree($list), self::get(), self::isLogin()); - } - - /** - * 后台主菜单权限过滤 - * @param array $menus 当前菜单列表 - * @param array $nodes 系统权限节点数据 - * @param bool $isLogin 是否已经登录 - * @return array - */ - private static function buildMenuData($menus, $nodes, $isLogin) - { - foreach ($menus as $key => &$menu) { - if (!empty($menu['sub'])) $menu['sub'] = self::buildMenuData($menu['sub'], $nodes, $isLogin); - if (!empty($menu['sub'])) $menu['url'] = '#'; - elseif (preg_match('/^https?\:/i', $menu['url'])) continue; - elseif ($menu['url'] !== '#') { - $node = join('/', array_slice(explode('/', preg_replace('/[\W]/', '/', $menu['url'])), 0, 3)); - $menu['url'] = url($menu['url']) . (empty($menu['params']) ? '' : "?{$menu['params']}"); - if (isset($nodes[$node]) && $nodes[$node]['is_login'] && empty($isLogin)) unset($menus[$key]); - elseif (isset($nodes[$node]) && $nodes[$node]['is_auth'] && $isLogin && !self::checkAuthNode($node)) unset($menus[$key]); - } else unset($menus[$key]); - } - return $menus; - } - - /** - * 检查密码是否合法 - * @param string $password - * @return array - */ - public static function checkPassword($password) - { - $password = trim($password); - if (!strlen($password) >= 6) { - return ['code' => 0, 'msg' => '密码必须大于6字符!']; - } - if (!preg_match("/^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,32}$/", $password)) { - return ['code' => 0, 'msg' => '密码必需包含大小写字母、数字、符号任意两者组合!']; - } - return ['code' => 1, 'msg' => '密码复杂度通过验证!']; - } - -} diff --git a/application/admin/service/Log.php b/application/admin/service/Log.php deleted file mode 100644 index 0f706f59f..000000000 --- a/application/admin/service/Log.php +++ /dev/null @@ -1,55 +0,0 @@ - Node::current(), - 'geoip' => PHP_SAPI === 'cli' ? '127.0.0.1' : request()->ip(), - 'action' => $action, - 'content' => $content, - 'username' => PHP_SAPI === 'cli' ? 'cli' : (string)session('user.username'), - ]; - return Db::name('SystemLog')->insert($data) !== false; - } - - /** - * 清理系统日志数据 - * @return boolean - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public static function clear() - { - return Db::name('SystemLog')->where('1=1')->delete() !== false; - } -} \ No newline at end of file diff --git a/application/admin/service/Message.php b/application/admin/service/Message.php deleted file mode 100644 index 2bb5a64b8..000000000 --- a/application/admin/service/Message.php +++ /dev/null @@ -1,72 +0,0 @@ - $title, 'desc' => $desc, 'url' => $url, 'code' => $code, 'node' => $node]; - return Db::name('SystemMessage')->insert($data) !== false; - } - - /** - * 系统消息状态更新 - * @param integer $code - * @return boolean - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public static function set($code) - { - $result = Db::name('SystemMessage')->where(['code' => $code, 'read_state' => '0'])->update([ - 'read_state' => '1', 'read_at' => date('Y-m-d H:i:s'), 'read_uid' => session('user.id'), - ]); - return $result !== false; - } - - /** - * 获取消息列表成功 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public static function gets() - { - $where = ['read_state' => '0']; - $list = Db::name('SystemMessage')->where($where)->order('id desc')->select(); - foreach ($list as $key => $vo) if (!empty($vo['node']) && !auth($vo['node'])) unset($list[$key]); - return $list; - } - -} \ No newline at end of file diff --git a/application/admin/service/Queue.php b/application/admin/service/Queue.php deleted file mode 100644 index 1ebd7b1b4..000000000 --- a/application/admin/service/Queue.php +++ /dev/null @@ -1,128 +0,0 @@ -insertGetId([ - 'title' => $title, 'later' => $later, 'uri' => $uri, 'double' => intval($double), - 'data' => json_encode($data, 256), 'desc' => $desc, 'status_at' => date('Y-m-d H:i:s'), - ]); - $data['_job_id_'] = $jobId; - $data['_job_title_'] = $title; - \think\Queue::later($later, $uri, $data); - } - - /** - * 更新任务状态 - * @param integer $jobId - * @param integer $status - * @param string $statusDesc - * @return boolean - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public static function status($jobId, $status = self::STATUS_PEND, $statusDesc = '') - { - $result = Db::name('SystemJobsLog')->where(['id' => $jobId])->update([ - 'status' => $status, 'status_desc' => $statusDesc, 'status_at' => date('Y-m-d H:i:s'), - ]); - return $result !== false; - } - - /** - * 检查任务是否存在 - * @param string $title - * @return boolean - */ - public static function exists($title) - { - $where = [['title', 'eq', $title], ['status', 'in', [1, 2]]]; - return Db::name('SystemJobsLog')->where($where)->count() > 0; - } - - /** - * 获取任务数据 - * @param integer $jobId - * @return array|null - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public static function get($jobId) - { - return Db::name('SystemJobsLog')->where(['id' => $jobId])->find(); - } - - /** - * 删除任务数据 - * @param integer $jobId - * @return boolean - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public static function del($jobId) - { - $where = [['id', 'eq', $jobId], ['status', 'in', [1, 3, 4]]]; - if (Db::name('SystemJobsLog')->where($where)->delete() > 0) { - Db::name('SystemJobs')->whereLike('payload', '%"_job_id_":"' . $jobId . '"%')->delete(); - return true; - } - return false; - } - -} \ No newline at end of file diff --git a/application/admin/sys.php b/application/admin/sys.php index 9524dbb62..77e37c3d7 100644 --- a/application/admin/sys.php +++ b/application/admin/sys.php @@ -20,10 +20,8 @@ if (!function_exists('auth')) { */ function auth($node) { - list($req, $num) = [request(), count(explode('/', $node))]; - if ($num === 1) $node = "{$req->module()}/{$req->controller()}/{$node}"; - if ($num === 2) $node = "{$req->module()}/{$node}"; - return \app\admin\service\Auth::checkAuthNode($node); + $real = \library\tools\Node::get($node); + return \app\admin\service\AuthService::checkAuthNode($real); } } @@ -39,10 +37,11 @@ if (!function_exists('sysdata')) { function sysdata($name, array $value = null) { if (is_null($value)) { - $data = json_decode(\think\Db::name('SystemData')->where('name', $name)->value('value'), true); + $data = json_decode(\think\Db::name('SystemData')->where(['name' => $name])->value('value'), true); return empty($data) ? [] : $data; + } else { + return data_save('SystemData', ['name' => $name, 'value' => json_encode($value, JSON_UNESCAPED_UNICODE)], 'name'); } - return data_save('SystemData', ['name' => $name, 'value' => json_encode($value, JSON_UNESCAPED_UNICODE)], 'name'); } } @@ -57,7 +56,7 @@ if (!function_exists('_sysmsg')) { */ function _sysmsg($title, $desc, $url, $node) { - return \app\admin\service\Message::add($title, $desc, $url, $node); + return \app\admin\service\MessageService::add($title, $desc, $url, $node); } } @@ -70,7 +69,7 @@ if (!function_exists('_syslog')) { */ function _syslog($action, $content) { - return \app\admin\service\Log::write($action, $content); + return \app\admin\service\OplogService::write($action, $content); } } @@ -83,8 +82,11 @@ if (!function_exists('local_image')) { function local_image($url) { $result = \library\File::down($url); - if (isset($result['url'])) return $result['url']; - return $url; + if (isset($result['url'])) { + return $result['url']; + } else { + return $url; + } } } @@ -102,8 +104,9 @@ if (!function_exists('base64_image')) { list($ext, $base) = explode('|||', preg_replace('|^data:image/(.*?);base64,|i', '$1|||', $content)); $info = \library\File::save($predir . md5($base) . '.' . (empty($ext) ? 'tmp' : $ext), base64_decode($base)); return $info['url']; + } else { + return $content; } - return $content; } catch (\Exception $e) { return $content; } @@ -113,21 +116,22 @@ if (!function_exists('base64_image')) { // 系统权限检查中间键 \think\facade\Middleware::add(function (\think\Request $request, \Closure $next) { // 系统消息处理 - if (($code = $request->get('messagecode')) > 0) \app\admin\service\Message::set($code); + if (($code = $request->get('messagecode')) > 0) \app\admin\service\MessageService::set($code); // 节点忽略跳过 $node = \library\tools\Node::current(); - foreach (\app\admin\service\Auth::getIgnore() as $str) if (stripos($node, $str) === 0) return $next($request); + foreach (\app\admin\service\AuthService::getIgnore() as $str) if (stripos($node, $str) === 0) return $next($request); // 节点权限查询 $auth = \think\Db::name('SystemNode')->cache(true, 60)->field('is_auth,is_login')->where(['node' => $node])->find(); $info = ['is_auth' => $auth['is_auth'], 'is_login' => $auth['is_auth'] ? 1 : $auth['is_login']]; // 登录状态检查 - if (!empty($info['is_login']) && !\app\admin\service\Auth::isLogin()) { + if (!empty($info['is_login']) && !\app\admin\service\AuthService::isLogin()) { $message = ['code' => 0, 'msg' => '抱歉,您还没有登录获取访问权限!', 'url' => url('@admin/login')]; return $request->isAjax() ? json($message) : redirect($message['url']); } // 访问权限检查 - if (!empty($info['is_auth']) && !\app\admin\service\Auth::checkAuthNode($node)) { + if (!empty($info['is_auth']) && !\app\admin\service\AuthService::checkAuthNode($node)) { return json(['code' => 0, 'msg' => '抱歉,您没有访问该模块的权限!']); + } else { + return $next($request); } - return $next($request); }); \ No newline at end of file diff --git a/application/admin/view/auth/index.html b/application/admin/view/auth/index.html index 119d50467..5c5a28e49 100644 --- a/application/admin/view/auth/index.html +++ b/application/admin/view/auth/index.html @@ -5,8 +5,8 @@ - - + + {/block} @@ -16,7 +16,7 @@ - + {notempty name='list'} - + {/notempty} - + {foreach $list as $key=>$vo} - + {/foreach}
{include file='auth/index_search'}
@@ -28,9 +28,9 @@
@@ -60,13 +60,13 @@ 启 用 {/if} - {if auth("admin/auth/del")} - 删 除 + {if auth("admin/auth/remove")} + 删 除 {/if}
diff --git a/application/admin/view/config/file.html b/application/admin/view/config/file.html index 4aeca1b90..450b5c8ff 100644 --- a/application/admin/view/config/file.html +++ b/application/admin/view/config/file.html @@ -4,11 +4,11 @@
-
-
+
+
- {foreach ['local'=>'本地服务器存储','oss'=>'阿里云OSS存储','qiniu'=>'七牛云存储'] as $k=>$v} + {foreach ['local'=>'本地服务器存储','qiniu'=>'七牛云对象存储','oss'=>'阿里云OSS存储'] as $k=>$v} {/foreach}

请选择文件存储类型,其它云储存需要配置正确的参数才可以上传文件哦!

@@ -17,9 +17,9 @@
-
{include file='config/file_oss'}
-
{include file='config/file_local'}
-
{include file='config/file_qiniu'}
+
{include file='config/file_oss'}
+
{include file='config/file_local'}
+
{include file='config/file_qiniu'}
@@ -30,14 +30,13 @@ $(function () { apply('{:sysconf("storage_type")}'); window.form.render(); - window.form.on('radio(storage_type)', function (data) { apply(data.value); }); function apply(value) { - var $active = $("[data-storagetype='" + value + "']").trigger('click'); - if ($active.size() < 1) $("[data-storagetype]:first").trigger('click'); + this.$active = $("[data-storagetype='" + value + "']").trigger('click'); + if (this.$active.size() < 1) $("[data-storagetype]:first").trigger('click'); $('[data-type="' + value + '"]').show().siblings('[data-type]').hide(); } }); diff --git a/application/admin/view/config/info.html b/application/admin/view/config/info.html index 3b834f5d1..5349bd25f 100644 --- a/application/admin/view/config/info.html +++ b/application/admin/view/config/info.html @@ -3,26 +3,26 @@ {block name="content"}
-
+
-

当前程序名称,在后台主标题上显示

+

当前程序名称,在后台主标题上显示 {:sysconf('app_name')}

-

当前程序版本号,在后台主标题上标显示

+

当前程序版本号,在后台主标题上标显示版本 {:sysconf('app_version')}

-

网站名称,显示在浏览器标签上

+

网站名称,将在浏览器的标签上显示 {:sysconf('site_name')}

@@ -38,14 +38,14 @@
-

程序的版权信息设置,在后台登录页面显示

+

程序的版权信息设置,在后台登录页面显示版本信息

- +
-

网站备案号,可以在备案管理中心查询获取

+

网站备案号,可以在备案管理中心查询获取,将在登录页面下面显示

diff --git a/application/admin/view/index/main.html b/application/admin/view/index/main.html index 8d2cfc91e..0431921a4 100644 --- a/application/admin/view/index/main.html +++ b/application/admin/view/index/main.html @@ -1,11 +1,120 @@ {extend name='main'} {block name='content'} -
+ + + +
+
商城统计
+
+
+
+
商品总量
+
63
+
当前商品总数量
+
+ +
+
+
+
用户总量
+
1,634
+
当前用户总数量
+
+ +
+
+
+
订单总量
+
148
+
已付款订单总数量
+
+ +
+
+
+
评价总量
+
0
+
订单评价总数量
+
+ +
+
+
+ +
+
实时概况
+
+
+
+
+ +
+
+
销售额(元)
+
1351.00
+
昨日:974.00
+
+
+
支付订单数
+
106
+
昨日:76
+
+
+
+
+
+
+ +
+
+
新增用户数
+
327
+
昨日:238
+
+
+
下单用户数
+
69
+
昨日:34
+
+
+
+
+
+ +
-
- 系统信息 +
+ @@ -44,12 +153,12 @@
系统信息
-
+
-
- 产品团队 +
+ @@ -92,7 +201,7 @@
产品团队
-
+
-{/block} +{/block} \ No newline at end of file diff --git a/application/admin/view/log/index.html b/application/admin/view/log/index.html deleted file mode 100644 index 28c526e50..000000000 --- a/application/admin/view/log/index.html +++ /dev/null @@ -1,68 +0,0 @@ -{extend name='main'} - -{block name="button"} - -{if auth("admin/log/clear")} - -{/if} - -{if auth("admin/log/del")} - -{/if} - -{/block} - -{block name="content"} -
- - - {notempty name='list'} - - - - - - - - - - - - - - - - - - - - - - - {/notempty} -
{include file='log/index_search'}
- - 操作权限位置操作时间
- - - 行为:{$vo.action|default='--'}
- 描述:{$vo.content|default='--'} -
- 账号:{$vo.username|default='--'}
- 节点:{$vo.node|default='--'} -
- 地址:{$vo.geoip|default='--'}
- 位置:{$vo.isp|default='--'} -
- 日期:{$vo.create_at|format_datetime|str_replace=' ','
时间:',###|raw} -
- {if auth("admin/log/del")} - 删 除 - {/if} -
- - {empty name='list'}没有记录哦{else}{$pagehtml|raw|default=''}{/empty} - -
- -{/block} \ No newline at end of file diff --git a/application/admin/view/log/index_search.html b/application/admin/view/log/index_search.html deleted file mode 100644 index 265e38001..000000000 --- a/application/admin/view/log/index_search.html +++ /dev/null @@ -1,56 +0,0 @@ -
- - 条件搜索 - - - -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- - -
- - \ No newline at end of file diff --git a/application/admin/view/menu/index.html b/application/admin/view/menu/index.html index 856ae6eb2..3d77cc842 100644 --- a/application/admin/view/menu/index.html +++ b/application/admin/view/menu/index.html @@ -6,17 +6,17 @@ - - + + {/block} {block name="content"}
- + {empty name='list'}
没 有 记 录 哦!
- + {else} @@ -33,7 +33,7 @@ - + {foreach $list as $key=>$vo} - + {/foreach}
@@ -66,15 +66,15 @@ 启 用 {/if} - {if auth("admin/menu/del")} - 删 除 + {if auth("admin/menu/remove")} + 删 除 {/if}
- + {/empty}
{/block} diff --git a/application/admin/view/message/index.html b/application/admin/view/message/index.html index 9d1736156..11581109c 100644 --- a/application/admin/view/message/index.html +++ b/application/admin/view/message/index.html @@ -2,7 +2,7 @@ {block name="button"} -{if auth("admin/message/onoff")} +{if auth("admin/message/state")}
{if sysconf('system_message_state')} @@ -11,7 +11,7 @@ {/if}