feat(ECR-021): AICoreConfig SystemPrompt 只读并 Closed

新增 system_prompts 目录、admin.ai_config.read 与 admin-h5「AI」页;本切片不改运行时 Prompt、禁写发布/UGC/真支付。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-08 00:27:17 +08:00
co-authored by Cursor
parent 22f9e358ae
commit 140b08ca01
33 changed files with 649 additions and 5 deletions
@@ -0,0 +1,4 @@
-- ECR-021 down
DELETE FROM admin_role_permissions WHERE code = 'admin.ai_config.read';
DROP TABLE IF EXISTS system_prompts;
@@ -0,0 +1,42 @@
-- ECR-021 AICoreConfig SystemPrompt (read catalog)
CREATE TABLE IF NOT EXISTS system_prompts (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
code varchar(64) NOT NULL UNIQUE,
title varchar(128) NOT NULL,
scene varchar(32) NULL,
body text NOT NULL,
version int NOT NULL DEFAULT 1 CHECK (version > 0),
active boolean NOT NULL DEFAULT true,
system boolean NOT NULL DEFAULT false,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_system_prompts_active ON system_prompts(active);
INSERT INTO system_prompts(code, title, scene, body, version, active, system)
VALUES (
'ask_default',
'问答默认系统提示',
NULL,
$prompt$你是 AI
宿
{{display_name}} · {{relation}} · {{birth_date}} · {{scene}} · {{report_ctx}}
$prompt$,
1,
true,
true
)
ON CONFLICT (code) DO NOTHING;
INSERT INTO admin_role_permissions(role_id, code)
SELECT r.id, 'admin.ai_config.read'
FROM admin_roles r
WHERE r.name = 'super_admin'
ON CONFLICT DO NOTHING;