mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 23:42:48 +08:00
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace base\admin\model;
|
|
|
|
use app\admin\model\SystemAuthNode;
|
|
use app\admin\service\NodeService;
|
|
use app\common\model\TimeModel;
|
|
|
|
class SystemAuthBase extends TimeModel
|
|
{
|
|
protected $deleteTime = 'delete_time';
|
|
|
|
/**
|
|
* 根据角色ID获取授权节点.
|
|
* @param $authId
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function getAuthorizeNodeListByAdminId($authId)
|
|
{
|
|
$checkNodeList = (new SystemAuthNode())
|
|
->where('auth_id', $authId)
|
|
->column('node');
|
|
|
|
$nodelList = (new NodeService())->getNodelist();
|
|
$newNodeList = [];
|
|
foreach ($nodelList as $vo) {
|
|
if ($vo['type'] == 1) {
|
|
$vo = array_merge($vo, ['field' => 'node', 'spread' => true]);
|
|
$vo['checked'] = false;
|
|
$vo['title'] = "{$vo['title']}【{$vo['node']}】";
|
|
$children = [];
|
|
foreach ($nodelList as $v) {
|
|
if ($v['type'] == 2 && strpos($v['node'], $vo['node'] . '/') !== false) {
|
|
$v = array_merge($v, ['field' => 'node', 'spread' => true]);
|
|
$v['checked'] = in_array($v['node'], $checkNodeList) ? true : false;
|
|
$v['title'] = "{$v['title']}【{$v['node']}】";
|
|
$children[] = $v;
|
|
}
|
|
}
|
|
!empty($children) && $vo['children'] = $children;
|
|
$newNodeList[] = $vo;
|
|
}
|
|
}
|
|
|
|
return $newNodeList;
|
|
}
|
|
}
|