mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-10-09 11:02:35 +00:00
24 lines
866 B
Python
24 lines
866 B
Python
import sqlalchemy as sa
|
|
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from backend.common.model import Base, TenantMixin, UniversalText, id_key
|
|
from backend.core.conf import settings
|
|
|
|
|
|
class Role(Base, TenantMixin):
|
|
"""角色表"""
|
|
|
|
__tablename__ = 'sys_role'
|
|
|
|
if settings.TENANT_ENABLED:
|
|
__table_args__ = (sa.UniqueConstraint('name', 'tenant_id'),)
|
|
else:
|
|
__table_args__ = (sa.UniqueConstraint('name'),)
|
|
|
|
id: Mapped[id_key] = mapped_column(init=False)
|
|
name: Mapped[str] = mapped_column(sa.String(32), comment='角色名称')
|
|
status: Mapped[int] = mapped_column(default=1, comment='角色状态(0停用 1正常)')
|
|
is_filter_scopes: Mapped[bool] = mapped_column(default=True, comment='过滤数据权限(0否 1是)')
|
|
remark: Mapped[str | None] = mapped_column(UniversalText, default=None, comment='备注')
|