File size: 1,300 Bytes
32ddb29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from datetime import datetime
from sqlalchemy import Boolean, DateTime, Integer, String, func
from sqlalchemy.orm import Mapped, mapped_column
from app.database import Base
class Role(Base):
__tablename__ = "role"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(30), unique=True, nullable=False, comment="角色名称")
code: Mapped[str] = mapped_column(String(30), unique=True, nullable=False, comment="角色编码")
description: Mapped[str | None] = mapped_column(String(200), comment="角色描述")
is_builtin: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否内置角色")
status: Mapped[int] = mapped_column(Integer, default=1, comment="1=启用 0=禁用")
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
class AdminRole(Base):
__tablename__ = "admin_role"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
admin_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="管理员ID")
role_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="角色ID")
|