mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
修复数据库初始化和Schema类型匹配问题
This commit is contained in:
@@ -21,10 +21,10 @@ class DeptModel(ModelMixin):
|
||||
parent: Mapped[Optional["DeptModel"]] = relationship("DeptModel", cascade="all, delete-orphan", uselist=False)
|
||||
|
||||
# 角色关联关系
|
||||
roles: Mapped[List["RoleModel"]] = relationship(secondary="system_role_depts", back_populates="depts", lazy="select")
|
||||
roles: Mapped[List["RoleModel"]] = relationship(secondary="system_role_depts", back_populates="depts", lazy="selectin")
|
||||
|
||||
# 用户关联关系
|
||||
users: Mapped[List["UserModel"]] = relationship(back_populates="dept", lazy="select")
|
||||
users: Mapped[List["UserModel"]] = relationship(back_populates="dept", lazy="selectin")
|
||||
|
||||
# code: Mapped[Optional[str]] = mapped_column(String(20),nullable=True,unique=True,comment="部门编码")
|
||||
# leader_id: Mapped[Optional[int]] = mapped_column(Integer,nullable=True,comment="负责人ID")
|
||||
|
||||
@@ -17,7 +17,7 @@ class DictTypeModel(CreatorMixin):
|
||||
|
||||
dict_name: Mapped[str] = mapped_column(String(100), nullable=False, unique=True, comment='字典名称')
|
||||
dict_type: Mapped[str] = mapped_column(String(100), nullable=False, unique=True, comment='字典类型')
|
||||
dict_datas: Mapped[List["DictDataModel"]] = relationship(back_populates="dict_type_rel", lazy="select")
|
||||
dict_datas: Mapped[List["DictDataModel"]] = relationship(back_populates="dict_type_rel", lazy="selectin")
|
||||
|
||||
|
||||
class DictDataModel(CreatorMixin):
|
||||
@@ -38,5 +38,5 @@ class DictDataModel(CreatorMixin):
|
||||
dict_type_id: Mapped[Optional[int]] = mapped_column(ForeignKey('system_dict_type.id'), nullable=True, comment='字典类型ID')
|
||||
|
||||
# 字典类型关联关系
|
||||
dict_type_rel: Mapped[Optional["DictTypeModel"]] = relationship(back_populates="dict_datas", lazy="select")
|
||||
dict_type_rel: Mapped[Optional["DictTypeModel"]] = relationship(back_populates="dict_datas", lazy="selectin")
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class MenuModel(ModelMixin):
|
||||
parent: Mapped[Optional['MenuModel']] = relationship(cascade='all, delete-orphan', primaryjoin="MenuModel.parent_id == MenuModel.id", uselist=False)
|
||||
|
||||
# 角色关联关系
|
||||
roles: Mapped[List["RoleModel"]] = relationship(secondary="system_role_menus", back_populates="menus", lazy="select")
|
||||
roles: Mapped[List["RoleModel"]] = relationship(secondary="system_role_menus", back_populates="menus", lazy="selectin")
|
||||
|
||||
# link: Mapped[Optional[str]] = mapped_column(String(255), comment='外链地址')
|
||||
# iframe: Mapped[Optional[str]] = mapped_column(String(255), comment='内嵌iframe地址')
|
||||
|
||||
@@ -23,7 +23,7 @@ class PositionModel(CreatorMixin):
|
||||
order: Mapped[int] = mapped_column(Integer, nullable=False, default=1, comment="显示排序")
|
||||
|
||||
# 用户关联关系
|
||||
users: Mapped[List["UserModel"]] = relationship(secondary="system_user_positions", back_populates="positions", lazy="select")
|
||||
users: Mapped[List["UserModel"]] = relationship(secondary="system_user_positions", back_populates="positions", lazy="selectin")
|
||||
|
||||
# users: Mapped[List["UserModel"]] = relationship(secondary="system_user_positions", back_populates="positions", lazy="select")
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class RoleModel(CreatorMixin):
|
||||
order: Mapped[int] = mapped_column(Integer, nullable=False, default=999, comment="显示排序")
|
||||
data_scope: Mapped[int] = mapped_column(Integer, nullable=False, default=1, comment="数据权限范围")
|
||||
|
||||
menus: Mapped[List["MenuModel"]] = relationship(secondary="system_role_menus", back_populates="roles", lazy="select")
|
||||
depts: Mapped[List["DeptModel"]] = relationship(secondary="system_role_depts", back_populates="roles", lazy="select")
|
||||
users: Mapped[List["UserModel"]] = relationship(secondary="system_user_roles", back_populates="roles", lazy="select")
|
||||
menus: Mapped[List["MenuModel"]] = relationship(secondary="system_role_menus", back_populates="roles", lazy="selectin")
|
||||
depts: Mapped[List["DeptModel"]] = relationship(secondary="system_role_depts", back_populates="roles", lazy="selectin")
|
||||
users: Mapped[List["UserModel"]] = relationship(secondary="system_user_roles", back_populates="roles", lazy="selectin")
|
||||
|
||||
|
||||
@@ -74,12 +74,12 @@ class UserModel(CreatorMixin):
|
||||
name: Mapped[str] = mapped_column(String(32),nullable=False,comment="昵称")
|
||||
mobile: Mapped[Optional[str]] = mapped_column(String(20),nullable=True,unique=True,comment="手机号")
|
||||
email: Mapped[Optional[str]] = mapped_column(String(64),nullable=True,unique=True,comment="邮箱")
|
||||
gender: Mapped[Optional[int]] = mapped_column(Integer,default=2,nullable=True,comment="性别(0:男 1:女 2:未知)")
|
||||
gender: Mapped[Optional[str]] = mapped_column(String(1), default='0',nullable=True,comment="性别(0:男 1:女 2:未知)")
|
||||
avatar: Mapped[Optional[str]] = mapped_column(String(500),nullable=True,comment="头像URL地址")
|
||||
is_superuser: Mapped[bool] = mapped_column(Boolean,default=False,nullable=False,comment="是否超管")
|
||||
last_login: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True),nullable=True,comment="最后登录时间")
|
||||
|
||||
dept_id: Mapped[Optional[int]] = mapped_column(Integer,ForeignKey('system_dept.id', ondelete="SET NULL", onupdate="CASCADE"),nullable=True, index=True, comment="部门ID")
|
||||
dept: Mapped[Optional["DeptModel"]] = relationship(back_populates="users",foreign_keys=[dept_id],lazy="select")
|
||||
roles: Mapped[List["RoleModel"]] = relationship(secondary="system_user_roles",back_populates="users",lazy="select")
|
||||
positions: Mapped[List["PositionModel"]] = relationship(secondary="system_user_positions",back_populates="users")
|
||||
dept: Mapped[Optional["DeptModel"]] = relationship(back_populates="users",foreign_keys=[dept_id],lazy="selectin")
|
||||
roles: Mapped[List["RoleModel"]] = relationship(secondary="system_user_roles",back_populates="users",lazy="selectin")
|
||||
positions: Mapped[List["PositionModel"]] = relationship(secondary="system_user_positions",back_populates="users",lazy="selectin")
|
||||
|
||||
Reference in New Issue
Block a user