模块修改
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
|
||||
//配置文件
|
||||
return [
|
||||
'exception_handle' => '\\app\\adminapi\\library\\ExceptionHandle',
|
||||
'exception_handle' => '\\app\\guildadmin\\library\\ExceptionHandle',
|
||||
];
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\controller;
|
||||
namespace app\guildadmin\controller;
|
||||
|
||||
use app\admin\command\Menu;
|
||||
use app\GuildAdmin\model\AuthGroup;
|
||||
use app\GuildAdmin\model\AuthGroupAccess;
|
||||
use app\GuildAdmin\model\AuthRule;
|
||||
use app\common\controller\GuildAdmin;
|
||||
use app\guildadmin\model\AuthGroup;
|
||||
use app\guildadmin\model\AuthGroupAccess;
|
||||
use app\guildadmin\model\AuthRule;
|
||||
use app\common\controller\guildadmin;
|
||||
use fast\Random;
|
||||
use fast\Tree;
|
||||
use think\Cache;
|
||||
@@ -21,7 +21,7 @@ use think\Validate;
|
||||
* @icon fa fa-users
|
||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||
*/
|
||||
class Admin extends GuildAdmin
|
||||
class Admin extends guildadmin
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -37,9 +37,9 @@ class Admin extends GuildAdmin
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('GuildAdmin/Admin');
|
||||
$this->authRuleModel = model('GuildAdmin/AuthRule');
|
||||
$this->authGroup = model('GuildAdmin/AuthGroup');
|
||||
$this->model = model('guildadmin/Admin');
|
||||
$this->authRuleModel = model('guildadmin/AuthRule');
|
||||
$this->authGroup = model('guildadmin/AuthGroup');
|
||||
$this->guildId = Session::get('guild_id');
|
||||
$this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin());
|
||||
$this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin());
|
||||
@@ -239,7 +239,7 @@ class Admin extends GuildAdmin
|
||||
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
||||
return V(0,'请选择正确的父角色', null);
|
||||
}
|
||||
$parentmodel = model("guildAdmin/AuthGroup")->get($params['pid']);
|
||||
$parentmodel = model("guildadmin/AuthGroup")->get($params['pid']);
|
||||
if (!$parentmodel) {
|
||||
return V(0,'请选择正确的父角色', null);
|
||||
}
|
||||
@@ -287,7 +287,7 @@ class Admin extends GuildAdmin
|
||||
}
|
||||
$params['rules'] = explode(',', $params['rules']);
|
||||
|
||||
$parentmodel = model("GuildAdmin/AuthGroup")->get($params['pid']);
|
||||
$parentmodel = model("guildadmin/AuthGroup")->get($params['pid']);
|
||||
if (!$parentmodel) {
|
||||
return V(0,'请选择正确的父角色', null);
|
||||
}
|
||||
@@ -305,13 +305,13 @@ class Admin extends GuildAdmin
|
||||
Db::startTrans();
|
||||
try {
|
||||
$row->save($params);
|
||||
$children_auth_groups = model("GuildAdmin/AuthGroup")->all(['id' => ['in', implode(',', (Tree::instance()->getChildrenIds($row->id)))]]);
|
||||
$children_auth_groups = model("guildadmin/AuthGroup")->all(['id' => ['in', implode(',', (Tree::instance()->getChildrenIds($row->id)))]]);
|
||||
$childparams = [];
|
||||
foreach ($children_auth_groups as $key => $children_auth_group) {
|
||||
$childparams[$key]['id'] = $children_auth_group->id;
|
||||
$childparams[$key]['rules'] = implode(',', array_intersect(explode(',', $children_auth_group->rules), $rules));
|
||||
}
|
||||
model("GuildAdmin/AuthGroup")->saveAll($childparams);
|
||||
model("guildadmin/AuthGroup")->saveAll($childparams);
|
||||
Db::commit();
|
||||
return V(1,"成功", null);
|
||||
} catch (Exception $e) {
|
||||
@@ -358,7 +358,7 @@ class Admin extends GuildAdmin
|
||||
|
||||
// 循环判断每一个组别是否可删除
|
||||
$grouplist = $this->authGroup->where('id', 'in', $ids)->select();
|
||||
$groupaccessmodel = model('GuildAdmin/AuthGroupAccess');
|
||||
$groupaccessmodel = model('guildadmin/AuthGroupAccess');
|
||||
foreach ($grouplist as $k => $v) {
|
||||
// 当前组别下有管理员
|
||||
$groupone = $groupaccessmodel->get(['group_id' => $v['id']]);
|
||||
@@ -387,7 +387,7 @@ class Admin extends GuildAdmin
|
||||
*/
|
||||
public function role_tree()
|
||||
{
|
||||
$model = model('GuildAdmin/AuthGroup');
|
||||
$model = model('guildadmin/AuthGroup');
|
||||
$id = $this->request->post("id");
|
||||
$pid = $this->request->post("pid");
|
||||
$parentGroupModel = $model->get($pid);
|
||||
@@ -398,7 +398,7 @@ class Admin extends GuildAdmin
|
||||
}
|
||||
if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) {
|
||||
$id = $id ? $id : null;
|
||||
$ruleList = collection(model('GuildAdmin/AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray();
|
||||
$ruleList = collection(model('guildadmin/AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray();
|
||||
//读取父类角色所有节点列表
|
||||
$parentRuleList = [];
|
||||
if (in_array('*', explode(',', $parentGroupModel->rules))) {
|
||||
@@ -417,7 +417,7 @@ class Admin extends GuildAdmin
|
||||
//当前所有正常规则列表
|
||||
$ruleTree->init($parentRuleList);
|
||||
//角色组列表
|
||||
$groupTree->init(collection(model('GuildAdmin/AuthGroup')->where('id', 'in', $this->childrenGroupIds)->select())->toArray());
|
||||
$groupTree->init(collection(model('guildadmin/AuthGroup')->where('id', 'in', $this->childrenGroupIds)->select())->toArray());
|
||||
|
||||
//读取当前角色下规则ID集合
|
||||
$adminRuleIds = $this->auth->getRuleIds();
|
||||
@@ -547,7 +547,7 @@ class Admin extends GuildAdmin
|
||||
foreach ($group as $value) {
|
||||
$dataset[] = ['uid' => $this->model->id, 'group_id' => $value];
|
||||
}
|
||||
model('guildAdmin/AuthGroupAccess')->saveAll($dataset);
|
||||
model('guildadmin/AuthGroupAccess')->saveAll($dataset);
|
||||
Db::commit();
|
||||
return V(1,"添加成功", []);
|
||||
} catch (\Exception $e) {
|
||||
@@ -598,7 +598,7 @@ class Admin extends GuildAdmin
|
||||
|
||||
if(!empty($group)){
|
||||
// 先移除所有权限
|
||||
model('guildAdmin/AuthGroupAccess')->where('uid', $params['id'])->delete();
|
||||
model('guildadmin/AuthGroupAccess')->where('uid', $params['id'])->delete();
|
||||
// 过滤不允许的组别,避免越权
|
||||
$group = array_intersect($this->childrenGroupIds, $group);
|
||||
if (!$group) {
|
||||
@@ -609,7 +609,7 @@ class Admin extends GuildAdmin
|
||||
foreach ($group as $value) {
|
||||
$dataset[] = ['uid' => $params['id'], 'group_id' => $value];
|
||||
}
|
||||
model('guildAdmin/AuthGroupAccess')->saveAll($dataset);
|
||||
model('guildadmin/AuthGroupAccess')->saveAll($dataset);
|
||||
}
|
||||
Db::commit();
|
||||
return V(1,"成功", []);
|
||||
@@ -698,7 +698,7 @@ class Admin extends GuildAdmin
|
||||
Db::startTrans();
|
||||
try {
|
||||
$this->model->destroy($deleteIds);
|
||||
model('guildAdmin/AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete();
|
||||
model('guildadmin/AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete();
|
||||
Db::commit();
|
||||
return V(1,"成功", []);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\controller;
|
||||
namespace app\guildadmin\controller;
|
||||
|
||||
use app\admin\command\Menu;
|
||||
use app\GuildAdmin\model\AuthGroup;
|
||||
use app\GuildAdmin\model\AuthGroupAccess;
|
||||
use app\GuildAdmin\model\AuthRule;
|
||||
use app\common\controller\GuildAdmin;
|
||||
use app\guildadmin\model\AuthGroup;
|
||||
use app\guildadmin\model\AuthGroupAccess;
|
||||
use app\guildadmin\model\AuthRule;
|
||||
use app\common\controller\guildadmin;
|
||||
use fast\Random;
|
||||
use fast\Tree;
|
||||
use think\Cache;
|
||||
@@ -22,7 +22,7 @@ use think\Validate;
|
||||
* @icon fa fa-users
|
||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||
*/
|
||||
class GuildData extends GuildAdmin
|
||||
class GuildData extends guildadmin
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\controller;
|
||||
namespace app\guildadmin\controller;
|
||||
|
||||
use app\common\controller\GuildAdmin;
|
||||
use app\common\controller\guildadmin;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
@@ -13,7 +13,7 @@ use think\Validate;
|
||||
* 后台首页
|
||||
* @internal
|
||||
*/
|
||||
class Index extends GuildAdmin
|
||||
class Index extends guildadmin
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['login'];
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\controller;
|
||||
namespace app\guildadmin\controller;
|
||||
|
||||
use app\admin\command\Menu;
|
||||
use app\GuildAdmin\model\AuthGroup;
|
||||
use app\GuildAdmin\model\AuthGroupAccess;
|
||||
use app\GuildAdmin\model\AuthRule;
|
||||
use app\common\controller\GuildAdmin;
|
||||
use app\guildadmin\model\AuthGroup;
|
||||
use app\guildadmin\model\AuthGroupAccess;
|
||||
use app\guildadmin\model\AuthRule;
|
||||
use app\common\controller\guildadmin;
|
||||
use fast\Random;
|
||||
use fast\Tree;
|
||||
use think\Cache;
|
||||
@@ -22,7 +22,7 @@ use think\Validate;
|
||||
* @icon fa fa-users
|
||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||
*/
|
||||
class Room extends GuildAdmin
|
||||
class Room extends guildadmin
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\library;
|
||||
namespace app\guildadmin\library;
|
||||
|
||||
use app\guildAdmin\model\Admin;
|
||||
use app\guildadmin\model\Admin;
|
||||
use fast\Random;
|
||||
use fast\Tree;
|
||||
use think\Cache;
|
||||
@@ -376,7 +376,7 @@ class Auth extends \fast\Auth
|
||||
}
|
||||
}
|
||||
// 取出所有分组
|
||||
$groupList = \app\guildAdmin\model\AuthGroup::where($this->isSuperAdmin() ? '1=1' : ['status' => 'normal'])->where('guild_id', Session::get('guild_id'))->select();
|
||||
$groupList = \app\guildadmin\model\AuthGroup::where($this->isSuperAdmin() ? '1=1' : ['status' => 'normal'])->where('guild_id', Session::get('guild_id'))->select();
|
||||
$objList = [];
|
||||
foreach ($groups as $k => $v) {
|
||||
if ($v['rules'] === '*') {
|
||||
@@ -408,7 +408,7 @@ class Auth extends \fast\Auth
|
||||
$childrenAdminIds = [];
|
||||
if (!$this->isSuperAdmin()) {
|
||||
$groupIds = $this->getChildrenGroupIds(false);
|
||||
$childrenAdminIds = \app\guildAdmin\model\AuthGroupAccess::where('group_id', 'in', $groupIds)
|
||||
$childrenAdminIds = \app\guildadmin\model\AuthGroupAccess::where('group_id', 'in', $groupIds)
|
||||
->column('uid');
|
||||
} else {
|
||||
//超级管理员拥有所有人的权限
|
||||
@@ -495,12 +495,12 @@ class Auth extends \fast\Auth
|
||||
$selected = $referer = [];
|
||||
$refererUrl = Session::get('referer');
|
||||
// 必须将结果集转换为数组
|
||||
$ruleList = collection(\app\guildAdmin\model\AuthRule::where('status', 'normal')
|
||||
$ruleList = collection(\app\guildadmin\model\AuthRule::where('status', 'normal')
|
||||
->where('ismenu', 1)
|
||||
->order('weigh', 'desc')
|
||||
->cache("__menu__")
|
||||
->select())->toArray();
|
||||
$indexRuleList = \app\guildAdmin\model\AuthRule::where('status', 'normal')
|
||||
$indexRuleList = \app\guildadmin\model\AuthRule::where('status', 'normal')
|
||||
->where('ismenu', 0)
|
||||
->where('name', 'like', '%/index')
|
||||
->column('name,pid');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\library;
|
||||
namespace app\guildadmin\library;
|
||||
|
||||
use Exception;
|
||||
use think\exception\Handle;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace app\guildAdmin\model;
|
||||
namespace app\guildadmin\model;
|
||||
|
||||
use fast\Random;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use app\guildAdmin\library\Auth;
|
||||
use app\guildadmin\library\Auth;
|
||||
|
||||
class Admin extends Model
|
||||
{
|
||||
@@ -51,13 +51,13 @@ class Admin extends Model
|
||||
'rules' => '*',
|
||||
'status' => 'normal'
|
||||
];
|
||||
$group = model('guildAdmin/AuthGroup')->create($group_data);
|
||||
$group = model('guildadmin/AuthGroup')->create($group_data);
|
||||
if (!$group) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
$dataset = [];
|
||||
$dataset[] = ['uid' => $this->id, 'group_id' => $group['id']];
|
||||
model('guildAdmin/AuthGroupAccess')->saveAll($dataset);
|
||||
model('guildadmin/AuthGroupAccess')->saveAll($dataset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\model;
|
||||
namespace app\guildadmin\model;
|
||||
|
||||
use app\admin\library\Auth;
|
||||
use think\Model;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\model;
|
||||
namespace app\guildadmin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\model;
|
||||
namespace app\guildadmin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\model;
|
||||
namespace app\guildadmin\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
|
||||
Reference in New Issue
Block a user