#!/usr/bin/env python # -*- coding: utf-8 -*- import datetime from sqlalchemy import Integer, Column, String, DateTime, Text, UniqueConstraint from db.base import Base class Role(Base): """角色 """ id = Column(Integer, primary_key=True, autoincrement=True) name = Column(String(128), nullable=False) remark = Column(String(255), nullable=True) platform = Column(String(50), nullable=True, comment="平台") permission_codes = Column(Text, nullable=True, comment="权限集合") creator_id = Column(Integer, comment="创建人ID") creator_name = Column(String(32), comment="创建人名称") created_at = Column(DateTime, default=datetime.datetime.now) editor_id = Column(Integer, comment="最后编辑人ID") editor_name = Column(String(32), comment="最后编辑人名称") updated_at = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now) __tablename__ = "sys_role" __table_args__ = (UniqueConstraint("name", name="uix_sysrole_name"),) class Permission(Base): """权限表 """ id = Column(Integer, primary_key=True, autoincrement=True) name = Column(String(128), nullable=False) codename = Column(String(255), nullable=True, comment="权限代码") remark = Column(String(255), nullable=True) api = Column(String(255), nullable=True) method = Column(String(255), nullable=True) platform = Column(String(50), nullable=True, comment="平台") order = Column(Integer, nullable=True, comment="排序字段", default=0) __tablename__ = "sys_permission" __table_args__ = (UniqueConstraint("name", name="uix_sysperms_name"),)