0.11.6: 渠道权限管控(部门范围 + 用户级授权)
- 迁移 000047:channels.department_ids(空=全局) + channel_grants 用户级授权 (source=manual/approval 区分来源)。 - 管理端:渠道部门范围配置 + 授权管理(列表/授予/撤销);渠道列表显示范围。 - 门户:我的渠道端点(/api/v1/portal/channels)按部门可见或明确授权返回, 「个人渠道」页新增可使用渠道区(授权方式标识)。 - 审批流:资源申请中的渠道类型通过后自动写 channel_grants(source=approval), 取代'批准记录即授权'的弱语义。 - 端到端验证:部门隔离(demo 无部门看不到)→手动授予→可见→撤销→不可见; 审批通过自动授权。修复 JOIN 列歧义与 uuid/text 比较。
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
-- 000047_channel_grants.sql — 渠道权限管控:部门范围 + 用户级授权。
|
||||
-- channels.department_ids:空数组 = 全局渠道(所有部门可见);非空 = 仅列出的
|
||||
-- 部门可见。channel_grants:渠道对具体门户用户的显式授权(管理员直接授予或
|
||||
-- 审批资源申请通过后自动写入)。
|
||||
|
||||
ALTER TABLE gateway.channels
|
||||
ADD COLUMN IF NOT EXISTS department_ids uuid[] NOT NULL DEFAULT '{}'::uuid[];
|
||||
|
||||
COMMENT ON COLUMN gateway.channels.department_ids IS
|
||||
'Departments allowed to see and use this channel. Empty array = global channel.';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS gateway.channel_grants (
|
||||
channel_id uuid NOT NULL REFERENCES gateway.channels(id) ON DELETE CASCADE,
|
||||
portal_user_id uuid NOT NULL REFERENCES gateway.portal_users(id) ON DELETE CASCADE,
|
||||
granted_by uuid REFERENCES gateway.admin_accounts(id) ON DELETE SET NULL,
|
||||
source varchar(16) NOT NULL DEFAULT 'manual' CHECK (source IN ('manual', 'approval')),
|
||||
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
PRIMARY KEY (channel_id, portal_user_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS channel_grants_user_idx
|
||||
ON gateway.channel_grants (portal_user_id, created_at DESC);
|
||||
Reference in New Issue
Block a user