12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import datetime
- from sqlalchemy import Integer, Column, String, DateTime, Text, UniqueConstraint, Enum
- from core.config import settings
- from db import BaseORMModel
- from common.enums import PlatformEnum, MethodEnum
- class Role(BaseORMModel):
- """
- 角色表
- """
- __tablename__ = "roles"
- __table_args__ = (UniqueConstraint("name", name="uix_roles_name"),)
- id = Column(Integer, primary_key=True, autoincrement=True, comment="角色ID")
- name = Column(String(128), nullable=False, comment="角色名称")
- remark = Column(String(255), default="", comment="备注")
- platform = Column(Enum(PlatformEnum), comment="平台类型")
- permission_codes = Column(Text, default="", comment="权限集合")
- permission_names = Column(Text, default="", comment="权限集合名称")
- creator_id = Column(Integer, default=1, comment="创建人ID")
- creator_name = Column(String(32), default=settings.ADMIN_USERNAME, comment="创建人名称")
- created_at = Column(DateTime, default=datetime.datetime.now)
- editor_id = Column(Integer, default=1, comment="最后编辑人ID")
- editor_name = Column(String(32), default=settings.ADMIN_USERNAME, comment="最后编辑人名称")
- updated_at = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
- class Permission(BaseORMModel):
- """权限表
- """
- __tablename__ = "permissions"
- __table_args__ = (UniqueConstraint("name", name="uix_permissions_name"),)
- id = Column(Integer, primary_key=True, autoincrement=True)
- name = Column(String(128), nullable=False, comment="权限名称")
- codename = Column(String(255), default="", comment="权限代码")
- module = Column(String(255), default="", comment="主模块")
- remark = Column(String(255), default="", comment="备注")
- api = Column(String(255), default="", comment="API接口")
- method = Column(Enum(MethodEnum), default=MethodEnum.GET, comment="接口方法")
- platform = Column(Enum(PlatformEnum), nullable=False, comment="平台类型")
- order = Column(Integer, default=0, comment="排序字段")
|