mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
38 lines
909 B
PHP
38 lines
909 B
PHP
<?php
|
|
|
|
namespace base\admin\model;
|
|
|
|
use app\common\model\TimeModel;
|
|
|
|
class SystemNodeBase extends TimeModel
|
|
{
|
|
protected $deleteTime = false;
|
|
|
|
public function getNodeTreeList()
|
|
{
|
|
$list = $this->select()->toArray();
|
|
$list = $this->buildNodeTree($list);
|
|
|
|
return $list;
|
|
}
|
|
|
|
protected function buildNodeTree($list)
|
|
{
|
|
$newList = [];
|
|
$repeatString = ' ';
|
|
foreach ($list as $vo) {
|
|
if ($vo['type'] == 1) {
|
|
$newList[] = $vo;
|
|
foreach ($list as $v) {
|
|
if ($v['type'] == 2 && strpos($v['node'], $vo['node'] . '/') !== false) {
|
|
$v['node'] = "{$repeatString}├{$repeatString}" . $v['node'];
|
|
$newList[] = $v;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return $newList;
|
|
}
|
|
}
|