Files
smart-project-pricing/后端服务/app/models/user.py
2026-01-31 21:33:06 +08:00

66 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""用户模型
与门户系统关联的用户信息
"""
from typing import List
from sqlalchemy import BigInteger, String, Boolean
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import BaseModel
class User(BaseModel):
"""用户表"""
__tablename__ = "users"
portal_user_id: Mapped[int] = mapped_column(
BigInteger,
unique=True,
nullable=False,
index=True,
comment="门户用户ID"
)
username: Mapped[str] = mapped_column(
String(50),
nullable=False,
comment="用户名"
)
role: Mapped[str] = mapped_column(
String(20),
nullable=False,
comment="角色admin-管理员, manager-经理, operator-操作员"
)
is_active: Mapped[bool] = mapped_column(
Boolean,
nullable=False,
default=True,
comment="是否启用"
)
# 关系
created_projects: Mapped[List["Project"]] = relationship(
"Project",
back_populates="creator"
)
operation_logs: Mapped[List["OperationLog"]] = relationship(
"OperationLog",
back_populates="user"
)
created_pricing_plans: Mapped[List["PricingPlan"]] = relationship(
"PricingPlan",
back_populates="creator"
)
created_profit_simulations: Mapped[List["ProfitSimulation"]] = relationship(
"ProfitSimulation",
back_populates="creator"
)
# 避免循环导入
from app.models.project import Project
from app.models.operation_log import OperationLog
from app.models.pricing_plan import PricingPlan
from app.models.profit_simulation import ProfitSimulation