chore: initial commit — leaudit-platform project skeleton
17-table PostgreSQL schema with full Chinese column comments, FastAPI project structure (admin/common/modules), DSL rule files, and schema migration scripts.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""BaseModel —— 所有业务模型的抽象基类。
|
||||
|
||||
自动提供三个公共时间字段:
|
||||
- create_time:INSERT 时由数据库写入当前时间
|
||||
- update_time:INSERT 和 UPDATE 时自动更新
|
||||
- delete_time:默认 NULL,非 NULL 表示已软删除
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from fastapi_common.fastapi_common_sqlalchemy.base import Base
|
||||
|
||||
|
||||
class BaseModel(Base):
|
||||
"""所有业务模型的抽象基类。"""
|
||||
|
||||
__abstract__ = True
|
||||
|
||||
create_time: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now(), comment="创建时间"
|
||||
)
|
||||
update_time: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), comment="更新时间"
|
||||
)
|
||||
delete_time: Mapped[datetime | None] = mapped_column(
|
||||
DateTime(timezone=True), default=None, comment="软删除时间"
|
||||
)
|
||||
Reference in New Issue
Block a user