模块修改
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user