This commit is contained in:
walkor 2022-12-22 14:41:07 +08:00
parent e9a06cdf67
commit db97119704
3 changed files with 19 additions and 10 deletions

View File

@ -2,6 +2,7 @@
namespace plugin\admin\app\controller; namespace plugin\admin\app\controller;
use plugin\admin\app\common\Auth;
use plugin\admin\app\common\Util; use plugin\admin\app\common\Util;
use plugin\admin\app\model\Admin; use plugin\admin\app\model\Admin;
use support\exception\BusinessException; use support\exception\BusinessException;
@ -107,14 +108,13 @@ class AccountController extends Crud
} }
$info = [ $info = [
'nickname' => $admin['nickname'], 'nickname' => $admin['nickname'],
'desc' => 'manager',
'avatar' => $admin['avatar'], 'avatar' => $admin['avatar'],
'token' => $request->sessionId(), 'token' => $request->sessionId(),
'userId' => $admin['id'], 'userId' => $admin['id'],
'username' => $admin['username'], 'username' => $admin['username'],
'email' => $admin['email'], 'email' => $admin['email'],
'mobile' => $admin['mobile'], 'mobile' => $admin['mobile'],
'roles' => [] 'isSupperAdmin' => Auth::isSupperAdmin()
]; ];
return $this->json(0, 'ok', $info); return $this->json(0, 'ok', $info);
} }

View File

@ -336,23 +336,21 @@ class Crud extends Base
/** /**
* 格式化树 * 格式化树
* @param $items * @param $items
* @param array $include
* @param int $type
* @return Response * @return Response
*/ */
protected function formatTree($items, array $include = [], int $type = 0): Response protected function formatTree($items): Response
{ {
$items_map = []; $format_items = [];
foreach ($items as $item) { foreach ($items as $item) {
$items_map[] = [ $format_items[] = [
'name' => $item->title ?? $item->name ?? $item->id, 'name' => $item->title ?? $item->name ?? $item->id,
'value' => (string)$item->id, 'value' => (string)$item->id,
'id' => $item->id, 'id' => $item->id,
'pid' => $item->pid, 'pid' => $item->pid,
]; ];
} }
$tree = new Tree($items_map); $tree = new Tree($format_items);
return $this->json(0, 'ok', $tree->getTree($include, $type)); return $this->json(0, 'ok', $tree->getTree());
} }
/** /**

View File

@ -166,7 +166,18 @@ class RoleController extends Crud
if ($rule_id_string !== '*') { if ($rule_id_string !== '*') {
$include = explode(',', $rule_id_string); $include = explode(',', $rule_id_string);
} }
return $this->formatTree($rules, $include); $items = [];
foreach ($rules as $item) {
$items[] = [
'name' => $item->title ?? $item->name ?? $item->id,
'value' => (string)$item->id,
'id' => $item->id,
'pid' => $item->pid,
];
}
$tree = new Tree($items);
return $this->json(0, 'ok', $tree->getTree($include));
} }
} }