29 lines
1.9 KiB
Python
29 lines
1.9 KiB
Python
|
|
"""授权版本锁及旧版授权结构;V26 后不再使用个人覆盖或全局制作人绑定。"""
|
|||
|
|
|
|||
|
|
from sqlalchemy import ForeignKey, Index, Integer, String, UniqueConstraint
|
|||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|||
|
|
|
|||
|
|
from app.models.base import BIGINT_UNSIGNED, Base, TimestampMixin, mysql_table_args
|
|||
|
|
|
|||
|
|
|
|||
|
|
class UserPermissionOverride(Base, TimestampMixin):
|
|||
|
|
__tablename__ = "user_permission_overrides"
|
|||
|
|
__table_args__ = mysql_table_args(
|
|||
|
|
"用户权限覆盖表(个人禁止优先)",
|
|||
|
|
UniqueConstraint("user_id", "permission_id", name="uk_user_permission_overrides_user_permission"),
|
|||
|
|
Index("idx_user_permission_overrides_permission_id", "permission_id"),
|
|||
|
|
)
|
|||
|
|
id: Mapped[int] = mapped_column(BIGINT_UNSIGNED, primary_key=True, autoincrement=True, comment="主键ID")
|
|||
|
|
user_id: Mapped[int] = mapped_column(BIGINT_UNSIGNED, ForeignKey("users.id", ondelete="CASCADE"), comment="系统用户ID")
|
|||
|
|
permission_id: Mapped[int] = mapped_column(BIGINT_UNSIGNED, ForeignKey("permissions.id", ondelete="RESTRICT"), comment="权限ID")
|
|||
|
|
effect: Mapped[str] = mapped_column(String(8), comment="个人覆盖:ALLOW允许 DENY禁止")
|
|||
|
|
|
|||
|
|
|
|||
|
|
class AuthorizationSetting(Base, TimestampMixin):
|
|||
|
|
__tablename__ = "authorization_settings"
|
|||
|
|
__table_args__ = mysql_table_args("授权设置表(单例与并发修改锁)")
|
|||
|
|
id: Mapped[int] = mapped_column(BIGINT_UNSIGNED, primary_key=True, autoincrement=True, comment="单例主键ID")
|
|||
|
|
maker_user_id: Mapped[int | None] = mapped_column(BIGINT_UNSIGNED, ForeignKey("users.id", ondelete="RESTRICT"), comment="现任工资制作人账号ID")
|
|||
|
|
revision: Mapped[int] = mapped_column(Integer, nullable=False, server_default="1", comment="全局授权版本")
|
|||
|
|
updated_by: Mapped[int | None] = mapped_column(BIGINT_UNSIGNED, ForeignKey("users.id", ondelete="SET NULL"), comment="最近修改人ID")
|