feat(admin): 运营后台(登录/查看/审核编辑/补全)+ 写入API + 审计留痕
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
DROP INDEX IF EXISTS idx_audit_created;
|
||||
DROP INDEX IF EXISTS idx_audit_entity;
|
||||
DROP TABLE IF EXISTS audit_log;
|
||||
DELETE FROM source WHERE name = 'manual';
|
||||
@@ -0,0 +1,22 @@
|
||||
-- Admin console support: manual edit provenance + audit log.
|
||||
|
||||
-- Manual-entry source used to record field-level provenance for operator edits.
|
||||
INSERT INTO source (name, homepage, license, trust_weight, notes)
|
||||
VALUES ('manual', NULL, 'proprietary', 0.90, '运营人工录入/补全')
|
||||
ON CONFLICT (name) DO NOTHING;
|
||||
|
||||
-- Audit trail: every admin write records actor, action, entity and before/after.
|
||||
CREATE TABLE IF NOT EXISTS audit_log (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
actor TEXT NOT NULL,
|
||||
action TEXT NOT NULL,
|
||||
entity TEXT NOT NULL,
|
||||
entity_id UUID,
|
||||
fields TEXT[] NOT NULL DEFAULT '{}',
|
||||
before JSONB,
|
||||
after JSONB,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_entity ON audit_log (entity, entity_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_created ON audit_log (created_at DESC);
|
||||
Reference in New Issue
Block a user