优化游戏渠道信息展示-只显示下级

This commit is contained in:
2026-04-02 11:36:01 +08:00
parent 81dc7de560
commit 9c03b92e4c
2 changed files with 31 additions and 8 deletions

View File

@@ -26,6 +26,12 @@ class Channel extends Backend
protected string|array $quickSearchField = ['id', 'code', 'name'];
/**
* 非超级管理员仅能操作 game_channel.admin_id 为当前账号的渠道;超管不限制
* @see \app\common\controller\Backend::getDataLimitAdminIds()
*/
protected bool|string|int $dataLimit = true;
/**
* adminTree 为辅助接口,默认权限节点名 game/channel/admintree 往往未在后台录入;
* 与列表权限 game/channel/index 对齐,避免子管理员已勾「渠道管理」仍 401。
@@ -50,11 +56,13 @@ class Channel extends Backend
return $this->error(__('You have no permission'));
}
$channels = Db::name('game_channel')
$channelQuery = Db::name('game_channel')
->field(['id', 'name', 'admin_group_id'])
->order('id', 'asc')
->select()
->toArray();
->order('id', 'asc');
if (!$this->auth->isSuperAdmin()) {
$channelQuery->where('admin_id', $this->auth->id);
}
$channels = $channelQuery->select()->toArray();
$groupChildrenCache = [];
$getGroupChildren = function ($groupId) use (&$getGroupChildren, &$groupChildrenCache) {
@@ -142,6 +150,10 @@ class Channel extends Backend
$data = $this->applyInputFilter($data);
$data = $this->excludeFields($data);
if (!$this->auth->isSuperAdmin()) {
$data['admin_id'] = $this->auth->id;
}
$adminId = $data['admin_id'] ?? null;
if ($adminId === null || $adminId === '') {
return $this->error(__('Parameter %s can not be empty', ['admin_id']));
@@ -228,6 +240,10 @@ class Channel extends Backend
unset($data['admin_group_id']);
}
if (!$this->auth->isSuperAdmin()) {
unset($data['admin_id']);
}
$nextAdminId = array_key_exists('admin_id', $data) ? $data['admin_id'] : ($row['admin_id'] ?? null);
if ($nextAdminId !== null && $nextAdminId !== '') {
$topGroupId = Db::name('admin_group_access')