修复发现的bug
This commit is contained in:
parent
e6a07b68c0
commit
8df8d2689a
@ -188,38 +188,6 @@ function get_article_cate()
|
|||||||
return $cate;
|
return $cate;
|
||||||
}
|
}
|
||||||
|
|
||||||
//读取指定分类下的文章列表
|
|
||||||
function get_article($cate_id = "")
|
|
||||||
{
|
|
||||||
$where = array();
|
|
||||||
if (!empty($cate_id)) {
|
|
||||||
$where['article_cate_id'] = $cate_id;
|
|
||||||
}
|
|
||||||
$article = \think\facade\Db::name('article')->where($where)->order('create_time desc')->paginate( get_config(app . page_size))->toArray();
|
|
||||||
return $article;
|
|
||||||
}
|
|
||||||
|
|
||||||
//读取指定文章的详情
|
|
||||||
function get_article_info($id)
|
|
||||||
{
|
|
||||||
$article = \think\facade\Db::name('article')->where(['id' => $id])->find();
|
|
||||||
if (empty($article)) {
|
|
||||||
return $this->error('文章不存在');
|
|
||||||
}
|
|
||||||
$keywrod_array = \think\facade\Db::name('ArticleKeywords')
|
|
||||||
->field('i.aid,i.keywords_id,k.title')
|
|
||||||
->alias('i')
|
|
||||||
->join('keywords k', 'k.id = i.keywords_id', 'LEFT')
|
|
||||||
->order('i.create_time asc')
|
|
||||||
->where(array('i.aid' => $id, 'k.status' => 1))
|
|
||||||
->select()->toArray();
|
|
||||||
|
|
||||||
$article['keyword_ids'] = implode(",", array_column($keywrod_array, 'keywords_id'));
|
|
||||||
$article['keyword_names'] = implode(',', array_column($keywrod_array, 'title'));
|
|
||||||
return $article;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员操作日志
|
* 管理员操作日志
|
||||||
* @param string $type 操作类型 login add edit view delete
|
* @param string $type 操作类型 login add edit view delete
|
||||||
|
@ -125,7 +125,7 @@ class Article extends BaseController
|
|||||||
$id = empty(get_params('id')) ? 0 : get_params('id');
|
$id = empty(get_params('id')) ? 0 : get_params('id');
|
||||||
View::assign('id', $id);
|
View::assign('id', $id);
|
||||||
if ($id > 0) {
|
if ($id > 0) {
|
||||||
$article = get_article_info($id);
|
$article = (new ArticleList())->detail($id);
|
||||||
View::assign('article', $article);
|
View::assign('article', $article);
|
||||||
return view('edit');
|
return view('edit');
|
||||||
}
|
}
|
||||||
|
@ -49,54 +49,49 @@ class Auth
|
|||||||
protected function checkAuth($controller, $pathInfo, $action, $uid)
|
protected function checkAuth($controller, $pathInfo, $action, $uid)
|
||||||
{
|
{
|
||||||
//Cache::delete('RulesSrc' . $uid);
|
//Cache::delete('RulesSrc' . $uid);
|
||||||
if ($uid == 1) {
|
if (!Cache::get('RulesSrc' . $uid) || !Cache::get('RulesSrc0')) {
|
||||||
// id=1的管理员默认拥有所有权限
|
//用户所在权限组及所拥有的权限
|
||||||
return true;
|
// 执行查询
|
||||||
} else {
|
$user_groups = Db::name('admin_group_access')
|
||||||
if (!Cache::get('RulesSrc' . $uid) || !Cache::get('RulesSrc0')) {
|
->alias('a')
|
||||||
//用户所在权限组及所拥有的权限
|
->join("admin_group g", "a.group_id=g.id", 'LEFT')
|
||||||
// 执行查询
|
->where("a.uid='{$uid}' and g.status='1'")
|
||||||
$user_groups = Db::name('admin_group_access')
|
->select()
|
||||||
->alias('a')
|
->toArray();
|
||||||
->join("admin_group g", "a.group_id=g.id", 'LEFT')
|
$groups = $user_groups ?: [];
|
||||||
->where("a.uid='{$uid}' and g.status='1'")
|
|
||||||
->select()
|
|
||||||
->toArray();
|
|
||||||
$groups = $user_groups ?: [];
|
|
||||||
|
|
||||||
$ids = []; //保存用户所属用户组设置的所有权限规则id
|
$ids = []; //保存用户所属用户组设置的所有权限规则id
|
||||||
foreach ($groups as $g) {
|
foreach ($groups as $g) {
|
||||||
$ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
|
$ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
|
||||||
}
|
}
|
||||||
$ids = array_unique($ids);
|
$ids = array_unique($ids);
|
||||||
//读取所有权限规则
|
//读取所有权限规则
|
||||||
$rules_all = Db::name('admin_rule')->field('src')->select();
|
$rules_all = Db::name('admin_rule')->field('src')->select();
|
||||||
//读取用户组所有权限规则
|
//读取用户组所有权限规则
|
||||||
$rules = Db::name('admin_rule')->where('id', 'in', $ids)->field('src')->select();
|
$rules = Db::name('admin_rule')->where('id', 'in', $ids)->field('src')->select();
|
||||||
//循环规则,判断结果。
|
//循环规则,判断结果。
|
||||||
$auth_list_all = [];
|
$auth_list_all = [];
|
||||||
$auth_list = [];
|
$auth_list = [];
|
||||||
foreach ($rules_all as $rule_all) {
|
foreach ($rules_all as $rule_all) {
|
||||||
$auth_list_all[] = strtolower($rule_all['src']);
|
$auth_list_all[] = strtolower($rule_all['src']);
|
||||||
}
|
}
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
$auth_list[] = strtolower($rule['src']);
|
$auth_list[] = strtolower($rule['src']);
|
||||||
}
|
}
|
||||||
//规则列表结果保存到Cache
|
//规则列表结果保存到Cache
|
||||||
Cache::tag('adminRules')->set('RulesSrc0', $auth_list_all, 36000);
|
Cache::tag('adminRules')->set('RulesSrc0', $auth_list_all, 36000);
|
||||||
Cache::tag('adminRules')->set('RulesSrc' . $uid, $auth_list, 36000);
|
Cache::tag('adminRules')->set('RulesSrc' . $uid, $auth_list, 36000);
|
||||||
} else {
|
} else {
|
||||||
$auth_list_all = Cache::get('RulesSrc0');
|
$auth_list_all = Cache::get('RulesSrc0');
|
||||||
$auth_list = Cache::get('RulesSrc' . $uid);
|
$auth_list = Cache::get('RulesSrc' . $uid);
|
||||||
}
|
}
|
||||||
if (!in_array((string) $controller . '/' . $pathInfo, $auth_list_all)) {
|
|
||||||
return true;
|
$pathUrl = $controller . '/' . $pathInfo;
|
||||||
}
|
if (!in_array($pathUrl , $auth_list) && !in_array($pathUrl, $auth_list_all)) {
|
||||||
else{
|
return false;
|
||||||
if (!in_array((string) $controller . '/' . $pathInfo, $auth_list)) {
|
}
|
||||||
return false;
|
else{
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,23 @@ namespace app\admin\model;
|
|||||||
use think\Model;
|
use think\Model;
|
||||||
class Article extends Model
|
class Article extends Model
|
||||||
{
|
{
|
||||||
|
// 获取文章详情
|
||||||
|
public function detail($id)
|
||||||
|
{
|
||||||
|
$article = \think\facade\Db::name('article')->where(['id' => $id])->find();
|
||||||
|
if (empty($article)) {
|
||||||
|
return $this->error('文章不存在');
|
||||||
|
}
|
||||||
|
$keywrod_array = \think\facade\Db::name('ArticleKeywords')
|
||||||
|
->field('i.aid,i.keywords_id,k.title')
|
||||||
|
->alias('i')
|
||||||
|
->join('keywords k', 'k.id = i.keywords_id', 'LEFT')
|
||||||
|
->order('i.create_time asc')
|
||||||
|
->where(array('i.aid' => $id, 'k.status' => 1))
|
||||||
|
->select()->toArray();
|
||||||
|
|
||||||
|
$article['keyword_ids'] = implode(",", array_column($keywrod_array, 'keywords_id'));
|
||||||
|
$article['keyword_names'] = implode(',', array_column($keywrod_array, 'title'));
|
||||||
|
return $article;
|
||||||
|
}
|
||||||
}
|
}
|
@ -110,7 +110,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (obj.event === 'del') {
|
if (obj.event === 'del') {
|
||||||
layer.confirm('您确定要删除该员工', {
|
layer.confirm('您确定要删除该账户', {
|
||||||
icon: 3,
|
icon: 3,
|
||||||
title: '提示'
|
title: '提示'
|
||||||
}, function (index) {
|
}, function (index) {
|
||||||
|
@ -96,7 +96,7 @@ INSERT INTO `cms_admin_menu` VALUES (8, 1, '权限角色', 'admin/role/index', '
|
|||||||
INSERT INTO `cms_admin_menu` VALUES (9, 1, '管 理 员', 'admin/admin/index', '', 1, 0, 0);
|
INSERT INTO `cms_admin_menu` VALUES (9, 1, '管 理 员', 'admin/admin/index', '', 1, 0, 0);
|
||||||
INSERT INTO `cms_admin_menu` VALUES (10, 1, '操作日志', 'admin/admin/log', '', 1, 0, 0);
|
INSERT INTO `cms_admin_menu` VALUES (10, 1, '操作日志', 'admin/admin/log', '', 1, 0, 0);
|
||||||
INSERT INTO `cms_admin_menu` VALUES (11, 1, '数据备份', 'admin/database/database', '', 1, 0, 0);
|
INSERT INTO `cms_admin_menu` VALUES (11, 1, '数据备份', 'admin/database/database', '', 1, 0, 0);
|
||||||
INSERT INTO `cms_admin_menu` VALUES (12, 1, '数据还原', 'admin/database/backupList', '', 1, 0, 0);
|
INSERT INTO `cms_admin_menu` VALUES (12, 1, '数据还原', 'admin/database/backuplist', '', 1, 0, 0);
|
||||||
INSERT INTO `cms_admin_menu` VALUES (13, 2, '导航设置', 'admin/nav/index', '', 1, 0, 0);
|
INSERT INTO `cms_admin_menu` VALUES (13, 2, '导航设置', 'admin/nav/index', '', 1, 0, 0);
|
||||||
INSERT INTO `cms_admin_menu` VALUES (14, 2, '网站地图', 'admin/sitemap/index', '', 1, 0, 0);
|
INSERT INTO `cms_admin_menu` VALUES (14, 2, '网站地图', 'admin/sitemap/index', '', 1, 0, 0);
|
||||||
INSERT INTO `cms_admin_menu` VALUES (15, 2, '轮播广告', 'admin/slide/index', '', 1, 0, 0);
|
INSERT INTO `cms_admin_menu` VALUES (15, 2, '轮播广告', 'admin/slide/index', '', 1, 0, 0);
|
||||||
@ -199,7 +199,7 @@ INSERT INTO `cms_admin_rule` VALUES (71, 70, 'admin/search/get_list', '关键字
|
|||||||
INSERT INTO `cms_admin_rule` VALUES (72, 70, 'admin/search/delete', '关键字搜索删除', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (72, 70, 'admin/search/delete', '关键字搜索删除', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (73, 3, 'admin/user/index', '用户管理', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (73, 3, 'admin/user/index', '用户管理', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (74, 73, 'admin/user/get_list', '用户管理列表', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (74, 73, 'admin/user/get_list', '用户管理列表', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (75, 73, 'admin/user/add', '修改用户', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (75, 73, 'admin/user/edit', '修改用户信息', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (76, 73, 'admin/user/post_submit', '用户保存', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (76, 73, 'admin/user/post_submit', '用户保存', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (77, 73, 'admin/user/view', '用户查看', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (77, 73, 'admin/user/view', '用户查看', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (78, 73, 'admin/user/delete', '用户禁用',0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (78, 73, 'admin/user/delete', '用户禁用',0, 0);
|
||||||
@ -219,9 +219,9 @@ INSERT INTO `cms_admin_rule` VALUES (91, 1, 'admin/database/database', '数据
|
|||||||
INSERT INTO `cms_admin_rule` VALUES (92, 91, 'admin/database/backup', '数据表备份', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (92, 91, 'admin/database/backup', '数据表备份', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (93, 91, 'admin/database/optimize', '数据表优化', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (93, 91, 'admin/database/optimize', '数据表优化', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (94, 91, 'admin/database/repair', '数据表修复', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (94, 91, 'admin/database/repair', '数据表修复', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (95, 1, 'admin/database/backupList', '数据还原', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (95, 1, 'admin/database/backuplist', '数据还原', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (96, 95, 'admin/database/import', '数据表还原', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (96, 95, 'admin/database/import', '数据表还原', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (97, 95, 'admin/database/downFile', '备份数据下载', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (97, 95, 'admin/database/downfile', '备份数据下载', 0, 0);
|
||||||
INSERT INTO `cms_admin_rule` VALUES (98, 95, 'admin/database/del', '删除备份数据', 0, 0);
|
INSERT INTO `cms_admin_rule` VALUES (98, 95, 'admin/database/del', '删除备份数据', 0, 0);
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for `cms_admin_log`
|
-- Table structure for `cms_admin_log`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user