2be0778ec7
- 后端:auth 路由(register/login/refresh/me)+ JWT + bcrypt 密码哈希 - 依赖注入:get_current_user + require_role 角色权限校验 - 跨数据库兼容:JSONBType(PG 用 JSONB,SQLite 用 JSON) - 测试:11 个认证测试 + 4 个健康检查测试 = 15 passed
40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
"""企业模型。
|
|
|
|
被投企业档案,包含基本信息、业务描述、投资关系等。
|
|
"""
|
|
|
|
import uuid
|
|
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.database import Base
|
|
from app.core.types import JSONBType
|
|
|
|
|
|
class Company(Base):
|
|
"""被投企业。"""
|
|
|
|
__tablename__ = "companies"
|
|
|
|
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)
|
|
name: Mapped[str] = mapped_column(String(200), nullable=False, comment="企业名称")
|
|
industry: Mapped[str | None] = mapped_column(String(100), nullable=True, comment="行业")
|
|
stage: Mapped[str | None] = mapped_column(String(50), nullable=True, comment="融资阶段:seed/a/b/c/ipo")
|
|
logo_url: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
|
description: Mapped[str | None] = mapped_column(Text, nullable=True, comment="业务描述")
|
|
founded_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
total_funding: Mapped[str | None] = mapped_column(String(50), nullable=True, comment="累计融资额")
|
|
website: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
|
extra_json: Mapped[dict | None] = mapped_column(JSONBType, nullable=True, comment="扩展字段")
|
|
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),
|
|
)
|