Files
opsxsql/backend/app/schemas/audit_rule.py
T
logan bab55d3927 feat: 审核规则模版+设置页面整合+去掉角色切换demo
后端:
- AuditRule 新增 value 字段, rule_type 扩展 DDL/DML
- MySQL/PG/Redis 预设规则种子接口 POST /audit-rules/seed/{db_type}
- 公告管理 CRUD (announcements)
- 消息推送 CRUD+测试 (notifications: 钉钉/飞书/邮件)
- LDAP 配置 CRUD+测试连接 (ldap-config)
- 164 tests passing (+31 新增)

前端:
- AuditRulesPage 重写: DB类型Tab+DDL/DML分组+参数编辑
- SettingsPage: 系统设置主页(审核规则/公告/推送/LDAP)
- NotificationPage: 钉钉/飞书/SMTP配置
- LdapConfigPage: LDAP设置+测试连接
- AnnouncementPage: 公告Markdown编辑
- 去掉左下角角色切换demo
- 侧边栏合并为: 系统设置(含审核规则+公告+推送+LDAP)
2026-05-22 22:26:10 +08:00

46 lines
1.5 KiB
Python

from datetime import datetime
from pydantic import BaseModel, Field
from typing import Optional, Literal
class AuditRuleCreate(BaseModel):
name: str = Field(..., min_length=1, max_length=100)
description: Optional[str] = None
rule_type: Literal["syntax", "performance", "safety", "naming", "DDL", "DML"]
severity: Literal["error", "warning", "info"] = "warning"
db_type: str = "mysql"
pattern: Optional[str] = None
value: Optional[str] = Field(default=None, max_length=255)
is_enabled: bool = True
message: str = Field(..., min_length=1, max_length=500)
class AuditRuleUpdate(BaseModel):
name: Optional[str] = Field(default=None, min_length=1, max_length=100)
description: Optional[str] = None
rule_type: Optional[Literal["syntax", "performance", "safety", "naming", "DDL", "DML"]] = None
severity: Optional[Literal["error", "warning", "info"]] = None
db_type: Optional[str] = None
pattern: Optional[str] = None
value: Optional[str] = Field(default=None, max_length=255)
is_enabled: Optional[bool] = None
message: Optional[str] = Field(default=None, min_length=1, max_length=500)
class AuditRuleResponse(BaseModel):
id: int
name: str
description: Optional[str] = None
rule_type: str
severity: str
db_type: str
pattern: Optional[str] = None
value: Optional[str] = None
is_enabled: bool
message: str
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True