feat: 初始化考培练系统项目

- 从服务器拉取完整代码
- 按框架规范整理项目结构
- 配置 Drone CI 测试环境部署
- 包含后端(FastAPI)、前端(Vue3)、管理端

技术栈: Vue3 + TypeScript + FastAPI + MySQL
This commit is contained in:
111
2026-01-24 19:33:28 +08:00
commit 998211c483
1197 changed files with 228429 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
"""基础模型定义"""
from datetime import datetime
from typing import Optional
from sqlalchemy import Column, DateTime, Integer, Boolean, func
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Mapped, mapped_column
# 创建基础模型类
Base = declarative_base()
class BaseModel(Base):
"""
基础模型类,所有模型都应继承此类
包含通用字段id, created_at, updated_at
时区使用北京时间Asia/Shanghai, UTC+8
"""
__abstract__ = True
__allow_unmapped__ = True # SQLAlchemy 2.0 兼容性
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
created_at: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), nullable=False, comment="创建时间(北京时间)"
)
updated_at: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), onupdate=func.now(), nullable=False, comment="更新时间(北京时间)"
)
class SoftDeleteMixin:
"""软删除混入类"""
__allow_unmapped__ = True
is_deleted: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
deleted_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
class AuditMixin:
"""审计字段混入类"""
__allow_unmapped__ = True
created_by: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
updated_by: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)