mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
同步系统模块
This commit is contained in:
parent
eb04fc4dde
commit
4f67b1057f
@ -17,9 +17,14 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\SystemAuth;
|
||||
use app\admin\model\SystemNode;
|
||||
use ReflectionException;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\service\AdminService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 系统权限管理
|
||||
@ -32,9 +37,9 @@ class Auth extends Controller
|
||||
* 系统权限管理
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -48,9 +53,9 @@ class Auth extends Controller
|
||||
/**
|
||||
* 添加系统权限
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@ -60,9 +65,9 @@ class Auth extends Controller
|
||||
/**
|
||||
* 编辑系统权限
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
@ -72,7 +77,7 @@ class Auth extends Controller
|
||||
/**
|
||||
* 修改权限状态
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
@ -85,7 +90,7 @@ class Auth extends Controller
|
||||
/**
|
||||
* 删除系统权限
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
@ -95,25 +100,26 @@ class Auth extends Controller
|
||||
/**
|
||||
* 权限配置节点
|
||||
* @auth true
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws ReflectionException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$map = $this->_vali(['auth.require#id' => '权限ID不能为空!']);
|
||||
if (input('action') === 'get') {
|
||||
if ($this->app->isDebug()) AdminService::instance()->clearCache();
|
||||
$checkeds = $this->app->db->name('SystemAuthNode')->where($map)->column('node');
|
||||
$this->success('获取权限节点成功!', AdminService::instance()->getTree($checkeds));
|
||||
$admin = AdminService::instance();
|
||||
if ($this->app->isDebug()) $admin->clearCache();
|
||||
$nodes = SystemNode::mk()->where($map)->column('node');
|
||||
$this->success('获取权限节点成功!', $admin->getTree($nodes));
|
||||
} elseif (input('action') === 'save') {
|
||||
[$post, $data] = [$this->request->post(), []];
|
||||
foreach ($post['nodes'] ?? [] as $node) {
|
||||
$data[] = ['auth' => $map['auth'], 'node' => $node];
|
||||
}
|
||||
$this->app->db->name('SystemAuthNode')->where($map)->delete();
|
||||
$this->app->db->name('SystemAuthNode')->insertAll($data);
|
||||
SystemNode::mk()->where($map)->delete();
|
||||
SystemNode::mk()->insertAll($data);
|
||||
sysoplog('系统权限管理', "配置系统权限[{$map['auth']}]授权成功");
|
||||
$this->success('访问权限修改成功!', 'javascript:history.back()');
|
||||
} else {
|
||||
|
@ -19,6 +19,9 @@ namespace app\admin\controller;
|
||||
use app\admin\model\SystemBase;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 数据字典管理
|
||||
@ -27,19 +30,13 @@ use think\admin\helper\QueryHelper;
|
||||
*/
|
||||
class Base extends Controller
|
||||
{
|
||||
/**
|
||||
* 绑定数据表
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'SystemBase';
|
||||
|
||||
/**
|
||||
* 数据字典管理
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -56,25 +53,25 @@ class Base extends Controller
|
||||
/**
|
||||
* 添加数据字典
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->_form($this->table, 'form');
|
||||
$this->_form(SystemBase::class, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据字典
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->_form($this->table, 'form');
|
||||
$this->_form(SystemBase::class, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +90,7 @@ class Base extends Controller
|
||||
$map[] = ['code', '=', $data['code']];
|
||||
$map[] = ['type', '=', $data['type']];
|
||||
if (isset($data['id'])) $map[] = ['id', '<>', $data['id']];
|
||||
if ($this->app->db->name($this->table)->where($map)->count() > 0) {
|
||||
if (SystemBase::mk()->where($map)->count() > 0) {
|
||||
$this->error("同类型的数据编码已经存在!");
|
||||
}
|
||||
}
|
||||
@ -102,20 +99,20 @@ class Base extends Controller
|
||||
/**
|
||||
* 修改数据状态
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
$this->_save($this->table);
|
||||
$this->_save(SystemBase::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据记录
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
$this->_delete($this->table);
|
||||
$this->_delete(SystemBase::class);
|
||||
}
|
||||
}
|
@ -23,6 +23,9 @@ use think\admin\service\SystemService;
|
||||
use think\admin\storage\AliossStorage;
|
||||
use think\admin\storage\QiniuStorage;
|
||||
use think\admin\storage\TxcosStorage;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 系统参数配置
|
||||
@ -47,9 +50,9 @@ class Config extends Controller
|
||||
/**
|
||||
* 修改系统参数
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function system()
|
||||
{
|
||||
@ -76,18 +79,22 @@ class Config extends Controller
|
||||
/**
|
||||
* 修改文件存储
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function storage()
|
||||
{
|
||||
$this->_applyFormToken();
|
||||
if ($this->request->isGet()) {
|
||||
$this->type = input('type', 'local');
|
||||
if ($this->type === 'alioss') $this->points = AliossStorage::region();
|
||||
elseif ($this->type === 'qiniu') $this->points = QiniuStorage::region();
|
||||
elseif ($this->type === 'txcos') $this->points = TxcosStorage::region();
|
||||
if ($this->type === 'alioss') {
|
||||
$this->points = AliossStorage::region();
|
||||
} elseif ($this->type === 'qiniu') {
|
||||
$this->points = QiniuStorage::region();
|
||||
} elseif ($this->type === 'txcos') {
|
||||
$this->points = TxcosStorage::region();
|
||||
}
|
||||
$this->fetch("storage-{$this->type}");
|
||||
} else {
|
||||
$post = $this->request->post();
|
||||
|
@ -17,9 +17,13 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\SystemUser;
|
||||
use ReflectionException;
|
||||
use think\admin\Controller;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\MenuService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 后台界面入口
|
||||
@ -31,10 +35,10 @@ class Index extends Controller
|
||||
|
||||
/**
|
||||
* 显示后台首页
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws ReflectionException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -58,9 +62,9 @@ class Index extends Controller
|
||||
* 修改用户资料
|
||||
* @login true
|
||||
* @param mixed $id 用户ID
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function info($id = 0)
|
||||
{
|
||||
@ -87,9 +91,9 @@ class Index extends Controller
|
||||
* 修改当前用户密码
|
||||
* @login true
|
||||
* @param mixed $id
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function pass($id = 0)
|
||||
{
|
||||
|
@ -16,11 +16,15 @@
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\SystemUser;
|
||||
use think\admin\Controller;
|
||||
use think\admin\extend\CodeExtend;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\CaptchaService;
|
||||
use think\admin\service\SystemService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 用户登录管理
|
||||
@ -32,9 +36,9 @@ class Login extends Controller
|
||||
|
||||
/**
|
||||
* 后台登录入口
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -45,12 +49,12 @@ class Login extends Controller
|
||||
$this->title = '系统登录';
|
||||
$this->captchaType = 'LoginCaptcha';
|
||||
$this->captchaToken = CodeExtend::uniqidDate(18);
|
||||
$this->devmode = SystemService::instance()->checkRunMode('dev');
|
||||
$this->devmode = SystemService::instance()->checkRunMode();
|
||||
// 刷新当前后台域名
|
||||
$host = "{$this->request->scheme()}://{$this->request->host()}";
|
||||
if ($host !== sysconf('base.site_host')) sysconf('base.site_host', $host);
|
||||
// 标记登录验证令牌
|
||||
if (!$this->app->session->get('login_input_session_error')) {
|
||||
if (!$this->app->session->get('LoginInputSessionError')) {
|
||||
$this->app->session->set($this->captchaType, $this->captchaToken);
|
||||
}
|
||||
$this->fetch();
|
||||
@ -68,22 +72,23 @@ class Login extends Controller
|
||||
$this->error('图形验证码验证失败,请重新输入!');
|
||||
}
|
||||
/*! 用户信息验证 */
|
||||
$map = ['username' => $data['username'], 'is_deleted' => '0'];
|
||||
$user = $this->app->db->name('SystemUser')->where($map)->order('id desc')->find();
|
||||
$map = ['username' => $data['username'], 'is_deleted' => 0];
|
||||
$user = SystemUser::mk()->where($map)->find();
|
||||
if (empty($user)) {
|
||||
$this->app->session->set("login_input_session_error", true);
|
||||
$this->error('登录账号或密码错误,请重新输入!');
|
||||
}
|
||||
if (md5("{$user['password']}{$data['uniqid']}") !== $data['password']) {
|
||||
$this->app->session->set("login_input_session_error", true);
|
||||
$this->app->session->set("LoginInputSessionError", true);
|
||||
$this->error('登录账号或密码错误,请重新输入!');
|
||||
}
|
||||
if (empty($user['status'])) {
|
||||
$this->app->session->set("LoginInputSessionError", true);
|
||||
$this->error('账号已经被禁用,请联系管理员!');
|
||||
}
|
||||
$this->app->session->set('user', $user);
|
||||
$this->app->session->delete("login_input_session_error");
|
||||
$this->app->db->name('SystemUser')->where(['id' => $user['id']])->update([
|
||||
if (md5("{$user['password']}{$data['uniqid']}") !== $data['password']) {
|
||||
$this->app->session->set("LoginInputSessionError", true);
|
||||
$this->error('登录账号或密码错误,请重新输入!');
|
||||
}
|
||||
$this->app->session->set('user', $user->toArray());
|
||||
$this->app->session->delete("LoginInputSessionError");
|
||||
$user->save([
|
||||
'login_ip' => $this->app->request->ip(),
|
||||
'login_at' => $this->app->db->raw('now()'),
|
||||
'login_num' => $this->app->db->raw('login_num+1'),
|
||||
|
@ -17,11 +17,15 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\SystemMenu;
|
||||
use ReflectionException;
|
||||
use think\admin\Controller;
|
||||
use think\admin\extend\DataExtend;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\MenuService;
|
||||
use think\admin\service\NodeService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 系统菜单管理
|
||||
@ -34,9 +38,9 @@ class Menu extends Controller
|
||||
* 系统菜单管理
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -75,9 +79,9 @@ class Menu extends Controller
|
||||
/**
|
||||
* 添加系统菜单
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@ -88,9 +92,9 @@ class Menu extends Controller
|
||||
/**
|
||||
* 编辑系统菜单
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
@ -101,7 +105,7 @@ class Menu extends Controller
|
||||
/**
|
||||
* 表单数据处理
|
||||
* @param array $vo
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
protected function _form_filter(array &$vo)
|
||||
{
|
||||
@ -134,7 +138,7 @@ class Menu extends Controller
|
||||
/**
|
||||
* 修改菜单状态
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
@ -148,7 +152,7 @@ class Menu extends Controller
|
||||
/**
|
||||
* 删除系统菜单
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
|
@ -16,10 +16,14 @@
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\SystemOplog;
|
||||
use Exception;
|
||||
use Ip2Region;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\service\AdminService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
@ -40,18 +44,16 @@ class Oplog extends Controller
|
||||
* 系统日志管理
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->_query($this->table)->layTable(function () {
|
||||
$this->_query(SystemOplog::class)->layTable(function () {
|
||||
$this->title = '系统日志管理';
|
||||
$this->isSupper = AdminService::instance()->isSuper();
|
||||
// 读取数据类型
|
||||
$this->users = $this->app->db->name($this->table)->distinct(true)->column('username');
|
||||
$this->actions = $this->app->db->name($this->table)->distinct(true)->column('action');
|
||||
$this->users = SystemOplog::mk()->distinct(true)->column('username');
|
||||
$this->actions = SystemOplog::mk()->distinct(true)->column('action');
|
||||
}, function (QueryHelper $query) {
|
||||
// 数据列表处理
|
||||
$query->dateBetween('create_at')->equal('username,action')->like('content,geoip,node');
|
||||
@ -66,11 +68,10 @@ class Oplog extends Controller
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
$region = new \Ip2Region();
|
||||
$region = new Ip2Region();
|
||||
foreach ($data as &$vo) {
|
||||
$isp = $region->btreeSearch($vo['geoip']);
|
||||
$vo['geoisp'] = str_replace(['内网IP', '0', '|'], '', $isp['region'] ?? '') ?: '-';
|
||||
$vo['create_at'] = format_datetime($vo['create_at']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +82,7 @@ class Oplog extends Controller
|
||||
public function clear()
|
||||
{
|
||||
try {
|
||||
$this->_query($this->table)->empty();
|
||||
$this->_query(SystemOplog::class)->empty();
|
||||
sysoplog('系统运维管理', '成功清理所有日志数据');
|
||||
$this->success('日志清理成功!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
@ -94,10 +95,10 @@ class Oplog extends Controller
|
||||
/**
|
||||
* 删除系统日志
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
$this->_delete($this->table);
|
||||
$this->_delete(SystemOplog::class);
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,15 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\SystemQueue;
|
||||
use Exception;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\ProcessService;
|
||||
use think\admin\service\QueueService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
@ -31,20 +35,13 @@ use think\exception\HttpResponseException;
|
||||
*/
|
||||
class Queue extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 绑定数据表
|
||||
* @var string
|
||||
*/
|
||||
private $table = 'SystemQueue';
|
||||
|
||||
/**
|
||||
* 系统任务管理
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -62,8 +59,7 @@ class Queue extends Controller
|
||||
}
|
||||
// 任务状态统计
|
||||
$this->total = ['dos' => 0, 'pre' => 0, 'oks' => 0, 'ers' => 0];
|
||||
$query = $this->app->db->name($this->table)->field('status,count(1) count');
|
||||
$query->group('status')->select()->map(function ($item) {
|
||||
SystemQueue::mk()->field('status,count(1) count')->group('status')->select()->map(function ($item) {
|
||||
if ($item['status'] === 1) $this->total['pre'] = $item['count'];
|
||||
if ($item['status'] === 2) $this->total['dos'] = $item['count'];
|
||||
if ($item['status'] === 3) $this->total['oks'] = $item['count'];
|
||||
@ -88,22 +84,11 @@ class Queue extends Controller
|
||||
$this->success('任务重置成功!', $queue->code);
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启任务结果处理
|
||||
* @param boolean $state
|
||||
*/
|
||||
protected function _redo_save_result(bool $state)
|
||||
{
|
||||
if ($state) {
|
||||
$this->success('重启任务成功!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理运行数据
|
||||
* @auth true
|
||||
@ -116,10 +101,10 @@ class Queue extends Controller
|
||||
/**
|
||||
* 删除系统任务
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
$this->_delete($this->table);
|
||||
$this->_delete(SystemQueue::class);
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,15 @@
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\SystemAuth;
|
||||
use app\admin\model\SystemBase;
|
||||
use app\admin\model\SystemUser;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\service\AdminService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 系统用户管理
|
||||
@ -29,32 +33,17 @@ use think\admin\service\AdminService;
|
||||
*/
|
||||
class User extends Controller
|
||||
{
|
||||
/**
|
||||
* 超级用户名称
|
||||
* @var string
|
||||
*/
|
||||
protected $superName;
|
||||
|
||||
/**
|
||||
* 控制器初始化
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
// 超级用户名称
|
||||
$this->superName = AdminService::instance()->getSuperName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统用户管理
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->type = input('type', 'index');
|
||||
$this->type = input('get.type', 'index');
|
||||
$this->_query(SystemUser::class)->layTable(function () {
|
||||
$this->title = '系统用户管理';
|
||||
$this->bases = SystemBase::mk()->items('身份权限');
|
||||
@ -83,9 +72,9 @@ class User extends Controller
|
||||
/**
|
||||
* 添加系统用户
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@ -95,9 +84,9 @@ class User extends Controller
|
||||
/**
|
||||
* 编辑系统用户
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
@ -107,9 +96,9 @@ class User extends Controller
|
||||
/**
|
||||
* 修改用户密码
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function pass()
|
||||
{
|
||||
@ -137,9 +126,9 @@ class User extends Controller
|
||||
/**
|
||||
* 表单数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
@ -161,20 +150,20 @@ class User extends Controller
|
||||
$data['password'] = md5($data['username']);
|
||||
}
|
||||
} else {
|
||||
// 用户身份数据
|
||||
$this->bases = SystemBase::mk()->items('身份权限');
|
||||
// 权限绑定处理
|
||||
$data['authorize'] = str2arr($data['authorize'] ?? '');
|
||||
// 用户身份数据
|
||||
$this->bases = SystemBase::mk()->items('身份权限');
|
||||
// 用户权限管理
|
||||
$query = $this->app->db->name('SystemAuth')->where(['status' => 1]);
|
||||
$this->authorizes = $query->order('sort desc,id desc')->select()->toArray();
|
||||
$this->superName = AdminService::instance()->getSuperName();
|
||||
$this->authorizes = SystemAuth::mk()->items();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
@ -188,7 +177,7 @@ class User extends Controller
|
||||
/**
|
||||
* 删除系统用户
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
|
@ -16,9 +16,13 @@
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
||||
use Exception;
|
||||
use think\admin\Controller;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\QueueService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
@ -32,9 +36,9 @@ class Queue extends Controller
|
||||
* 任务进度查询
|
||||
* @login true
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function progress()
|
||||
{
|
||||
@ -61,7 +65,7 @@ class Queue extends Controller
|
||||
}
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
@ -84,7 +88,7 @@ class Queue extends Controller
|
||||
}
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
@ -102,7 +106,7 @@ class Queue extends Controller
|
||||
} else {
|
||||
echo '<span class="color-red">' . $message . '</span>';
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
echo '<span class="color-red">' . $exception->getMessage() . '</span>';
|
||||
} else {
|
||||
echo '<span class="color-red">只有超级管理员才能操作!</span>';
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
||||
use Exception;
|
||||
use think\admin\Controller;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\SystemService;
|
||||
@ -42,7 +43,7 @@ class Runtime extends Controller
|
||||
$this->success('网站缓存加速成功!', 'javascript:location.reload()');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
} else {
|
||||
$this->error('只有超级管理员才能操作!');
|
||||
@ -62,7 +63,7 @@ class Runtime extends Controller
|
||||
$this->success('清空缓存日志成功!', 'javascript:location.reload()');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
} else {
|
||||
$this->error('只有超级管理员才能操作!');
|
||||
@ -110,7 +111,7 @@ class Runtime extends Controller
|
||||
$this->success('清理系统配置成功!', 'javascript:location.reload()');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
} else {
|
||||
$this->error('只有超级管理员才能操作!');
|
||||
|
@ -16,12 +16,16 @@
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
||||
use Exception;
|
||||
use think\admin\Controller;
|
||||
use think\admin\Storage;
|
||||
use think\admin\storage\AliossStorage;
|
||||
use think\admin\storage\LocalStorage;
|
||||
use think\admin\storage\QiniuStorage;
|
||||
use think\admin\storage\TxcosStorage;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\file\UploadedFile;
|
||||
use think\Response;
|
||||
@ -37,9 +41,9 @@ class Upload extends Controller
|
||||
/**
|
||||
* 文件上传脚本
|
||||
* @return Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
@ -57,9 +61,9 @@ class Upload extends Controller
|
||||
* 文件上传检查
|
||||
* @login true
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
@ -99,9 +103,9 @@ class Upload extends Controller
|
||||
/**
|
||||
* 文件上传入口
|
||||
* @login true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function file()
|
||||
{
|
||||
@ -148,7 +152,7 @@ class Upload extends Controller
|
||||
}
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
@ -165,9 +169,9 @@ class Upload extends Controller
|
||||
/**
|
||||
* 获取文件上传方式
|
||||
* @return string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
private function getType(): string
|
||||
{
|
||||
@ -194,7 +198,7 @@ class Upload extends Controller
|
||||
}
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
$this->error(lang($exception->getMessage()));
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,9 @@
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\admin\Model;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 用户权限模型
|
||||
@ -37,6 +40,18 @@ class SystemAuth extends Model
|
||||
*/
|
||||
protected $oplogType = '系统权限管理';
|
||||
|
||||
/**
|
||||
* 获取权限数据
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function items(): array
|
||||
{
|
||||
return $this->where(['status' => 1])->order('sort desc,id desc')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除权限事件
|
||||
* @param string $ids
|
||||
@ -44,7 +59,7 @@ class SystemAuth extends Model
|
||||
public function onAdminDelete(string $ids)
|
||||
{
|
||||
if (count($aids = str2arr($ids ?? '')) > 0) {
|
||||
M('SystemAuthNode')->whereIn('auth', $aids)->delete();
|
||||
SystemNode::mk()->whereIn('auth', $aids)->delete();
|
||||
}
|
||||
sysoplog($this->oplogType, "删除{$this->oplogName}[{$ids}]及授权配置");
|
||||
}
|
||||
|
@ -19,12 +19,24 @@ namespace app\admin\model;
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 数据字典数据模型
|
||||
* 数据字典模型
|
||||
* Class SystemBase
|
||||
* @package app\admin\model
|
||||
*/
|
||||
class SystemBase extends Model
|
||||
{
|
||||
/**
|
||||
* 日志名称
|
||||
* @var string
|
||||
*/
|
||||
protected $oplogName = '数据字典';
|
||||
|
||||
/**
|
||||
* 日志类型
|
||||
* @var string
|
||||
*/
|
||||
protected $oplogType = '数据字典管理';
|
||||
|
||||
/**
|
||||
* 获取指定数据列表
|
||||
* @param string $type 数据类型
|
||||
|
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免费声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\admin\Model;
|
||||
@ -22,4 +36,14 @@ class SystemMenu extends Model
|
||||
* @var string
|
||||
*/
|
||||
protected $oplogType = '系统菜单管理';
|
||||
|
||||
/**
|
||||
* 格式化创建时间
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateAtAttr(string $value): string
|
||||
{
|
||||
return format_datetime($value);
|
||||
}
|
||||
}
|
43
app/admin/model/SystemNode.php
Normal file
43
app/admin/model/SystemNode.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免费声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 授权节点模型
|
||||
* Class SystemNode
|
||||
* @package app\admin\model
|
||||
*/
|
||||
class SystemNode extends Model
|
||||
{
|
||||
/**
|
||||
* 绑定模型名称
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'SystemAuthNode';
|
||||
|
||||
/**
|
||||
* 格式化创建时间
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateAtAttr(string $value): string
|
||||
{
|
||||
return format_datetime($value);
|
||||
}
|
||||
}
|
37
app/admin/model/SystemOplog.php
Normal file
37
app/admin/model/SystemOplog.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免费声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 系统日志模型
|
||||
* Class SystemOplog
|
||||
* @package app\admin\model
|
||||
*/
|
||||
class SystemOplog extends Model
|
||||
{
|
||||
/**
|
||||
* 格式化创建时间
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateAtAttr(string $value): string
|
||||
{
|
||||
return format_datetime($value);
|
||||
}
|
||||
}
|
@ -19,13 +19,12 @@ namespace app\admin\model;
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 系统任务数据模型
|
||||
* 系统任务模型
|
||||
* Class SystemQueue
|
||||
* @package app\admin\model
|
||||
*/
|
||||
class SystemQueue extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* 格式化计划时间
|
||||
* @param float $value
|
||||
|
@ -19,7 +19,7 @@ namespace app\admin\model;
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 系统用户数据模型
|
||||
* 系统用户模型
|
||||
* Class SystemUser
|
||||
* @package app\admin\model
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user