0.11.0: 旗舰版功能补齐(License/登录记录/会话管理/角色管理/门户定时任务/模型配额/输出脱敏/供应链扫描/记忆管理/AI助手/真实概览)
- 新增迁移 000031-000034(登录日志/角色/模型配额/记忆) - 新增包: license/memory/modelquota/assistant,扫描引擎 - 全部功能后端+前端+端到端验证通过(25 包单测)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
-- 登录审计:记录管理端/门户每次登录尝试(成功/失败与原因),供个人中心
|
||||
-- 与管理端查询,满足"登录记录查看"需求。
|
||||
CREATE TABLE IF NOT EXISTS gateway.login_logs (
|
||||
id uuid PRIMARY KEY,
|
||||
kind text NOT NULL CHECK (kind IN ('admin', 'portal')),
|
||||
login text NOT NULL,
|
||||
success boolean NOT NULL,
|
||||
ip inet,
|
||||
user_agent text NOT NULL DEFAULT '',
|
||||
reason text NOT NULL DEFAULT '',
|
||||
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS login_logs_kind_idx
|
||||
ON gateway.login_logs (kind, created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS login_logs_login_idx
|
||||
ON gateway.login_logs (login, created_at DESC);
|
||||
@@ -0,0 +1,14 @@
|
||||
-- 自定义角色管理:在内置角色(superadmin/operator/auditor/member)之外,
|
||||
-- 管理员可定义任意角色并为其分配权限字符串;绑定账号时权限展开写入
|
||||
-- 账号 permissions(与内置角色权限合并生效)。
|
||||
CREATE TABLE IF NOT EXISTS gateway.roles (
|
||||
id uuid PRIMARY KEY,
|
||||
code text NOT NULL UNIQUE,
|
||||
name text NOT NULL,
|
||||
description text NOT NULL DEFAULT '',
|
||||
permissions text[] NOT NULL DEFAULT '{}',
|
||||
builtin boolean NOT NULL DEFAULT false,
|
||||
created_by uuid,
|
||||
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
updated_at timestamptz NOT NULL DEFAULT clock_timestamp()
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
-- 模型级 Token 配额:按 Provider + 模型模式设置企业总配额(所有 API Key
|
||||
-- 共享同一计数),用于成本管控。配额键按自然月滚动,与 API Key 级配额
|
||||
-- 相互独立、叠加生效。
|
||||
CREATE TABLE IF NOT EXISTS gateway.model_quotas (
|
||||
id uuid PRIMARY KEY,
|
||||
provider_code text NOT NULL,
|
||||
model_pattern text NOT NULL,
|
||||
monthly_token_quota bigint NOT NULL CHECK (monthly_token_quota > 0),
|
||||
enabled boolean NOT NULL DEFAULT true,
|
||||
updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
UNIQUE (provider_code, model_pattern)
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
-- 记忆管理(旗舰版):支持用户个人记忆/部门记忆/全局记忆的多层记忆集合,
|
||||
-- 内容向量化后按语义召回(与知识库共用 Ollama embedding);支持向其他
|
||||
-- 用户授权(shared_with);按重要度与最近访问时间做衰减清理。
|
||||
CREATE TABLE IF NOT EXISTS gateway.memory_entries (
|
||||
id uuid PRIMARY KEY,
|
||||
owner_kind text NOT NULL CHECK (owner_kind IN ('user', 'department', 'global')),
|
||||
owner_id text NOT NULL DEFAULT '',
|
||||
category text NOT NULL DEFAULT 'general',
|
||||
content text NOT NULL,
|
||||
importance int NOT NULL DEFAULT 5 CHECK (importance BETWEEN 1 AND 10),
|
||||
embedding vector(1024),
|
||||
shared_with uuid[] NOT NULL DEFAULT '{}',
|
||||
source text NOT NULL DEFAULT '',
|
||||
last_accessed_at timestamptz,
|
||||
created_by uuid,
|
||||
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
updated_at timestamptz NOT NULL DEFAULT clock_timestamp()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_owner_idx
|
||||
ON gateway.memory_entries (owner_kind, owner_id, created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_shared_idx
|
||||
ON gateway.memory_entries USING gin (shared_with);
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_vector_idx
|
||||
ON gateway.memory_entries USING hnsw (embedding vector_cosine_ops);
|
||||
Reference in New Issue
Block a user