Initial commit: 智能项目定价模型
This commit is contained in:
66
后端服务/app/models/user.py
Normal file
66
后端服务/app/models/user.py
Normal file
@@ -0,0 +1,66 @@
|
||||
"""用户模型
|
||||
|
||||
与门户系统关联的用户信息
|
||||
"""
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user