feat: 完善前后端核心功能模块
后端: - 新增认证(auth)、任务(tasks)、映射(mappings)、对账(reconciliation)、异常(exceptions)、导出(exports) API - 新增核心模块: database, security, permissions, tenant, exceptions, error_handlers - 新增数据模型: user, company, reconciliation_task, field_mapping, uploaded_file 等 - 新增服务层: ai_recognizer, file_parser, file_storage, mapping, reconciliation 等 - 添加数据库迁移脚本 前端: - 新增登录页面和仪表盘页面 - 新增任务列表、任务详情、字段映射页面 - 新增异常处理页面和规则设置页面 - 新增 API 代理路由 /api/[...path] - 新增 UI 组件库 (button, card, dialog, input, table 等) - 新增 auth 组件 (ProtectedRoute, PermissionGate) - 新增 layout 组件 (Header, Sidebar) - 新增 mapping 组件 (FieldMappingTable, AISuggestionPanel) - 新增 API 客户端和 hooks (useAsync, useToast, usePermission 等) - 新增状态管理 (auth-store, company-store, ui-store) - 集成 Tailwind CSS 和 shadcn/ui 组件库 其他: - 添加 Alembic 数据库迁移配置 - 添加初始化示例数据脚本 - 更新项目文档
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
from enum import Enum
|
||||
|
||||
from sqlalchemy import Integer, JSON, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import BaseModel
|
||||
|
||||
|
||||
class AuditAction(str, Enum):
|
||||
"""审计操作类型"""
|
||||
CREATE = "CREATE"
|
||||
UPDATE = "UPDATE"
|
||||
DELETE = "DELETE"
|
||||
VIEW = "VIEW"
|
||||
EXPORT = "EXPORT"
|
||||
LOGIN = "LOGIN"
|
||||
LOGOUT = "LOGOUT"
|
||||
UPLOAD = "UPLOAD"
|
||||
DOWNLOAD = "DOWNLOAD"
|
||||
|
||||
|
||||
class AuditLog(BaseModel):
|
||||
"""
|
||||
审计日志模型
|
||||
记录所有关键业务操作
|
||||
|
||||
Attributes:
|
||||
company_id: 企业 ID
|
||||
user_id: 用户 ID
|
||||
action: 操作类型
|
||||
resource_type: 资源类型 (如 company, user, task, file)
|
||||
resource_id: 资源 ID
|
||||
details: 操作详情 (JSON)
|
||||
ip_address: IP 地址
|
||||
user_agent: User-Agent
|
||||
"""
|
||||
|
||||
__tablename__ = "audit_logs"
|
||||
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
user_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
|
||||
action: Mapped[str] = mapped_column(String(50), nullable=False, index=True)
|
||||
resource_type: Mapped[str] = mapped_column(String(100), nullable=False, index=True)
|
||||
resource_id: Mapped[str | None] = mapped_column(String(200), nullable=True, index=True)
|
||||
details: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
||||
ip_address: Mapped[str | None] = mapped_column(String(50), nullable=True)
|
||||
user_agent: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f"<AuditLog(id={self.id}, company_id={self.company_id}, "
|
||||
f"action='{self.action}', resource_type='{self.resource_type}')>"
|
||||
)
|
||||
Reference in New Issue
Block a user