51feae55ba
- 后端:FastAPI + SQLAlchemy + Alembic,7 张核心表迁移成功 - 前端:Next.js 16 + TailwindCSS 4 + 三端布局(投资人/创始人/Admin) - 数据库:PostgreSQL 16,7 张核心实体表(tenants/users/companies/monthly_reports/health_scores/risk_events/audit_logs) - Docker:docker-compose.yml + 前后端 Dockerfile - 测试:健康检查 4 个测试全部 GREEN - 文档:README/run.md/AGENTS.md/docs 体系完整
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""用户模型。
|
|
|
|
支持多种角色:GP、投资经理、投后负责人、创始人、管理员等。
|
|
"""
|
|
|
|
import uuid
|
|
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import Boolean, DateTime, ForeignKey, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class User(Base):
|
|
"""用户。"""
|
|
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
tenant_id: Mapped[str] = mapped_column(String(36), ForeignKey("tenants.id"), nullable=False, index=True)
|
|
email: Mapped[str] = mapped_column(String(255), unique=True, nullable=False, index=True)
|
|
password_hash: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
name: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
role: Mapped[str] = mapped_column(
|
|
String(50), nullable=False, default="investor",
|
|
comment="角色:gp/partner/post_invest_lead/investor/founder/admin",
|
|
)
|
|
phone: Mapped[str | None] = mapped_column(String(20), nullable=True)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True),
|
|
default=lambda: datetime.now(timezone.utc),
|
|
onupdate=lambda: datetime.now(timezone.utc),
|
|
)
|