You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
from tortoise import fields, models
|
|
|
|
|
|
class UserType:
|
|
SUPER_ADMIN = 100, '超级管理员'
|
|
ADMIN = 20, '管理员'
|
|
USER = 0, '普通用户'
|
|
|
|
|
|
class Role(models.Model):
|
|
id = fields.IntField(pk=True,)
|
|
name = fields.CharField(max_length=100, description='角色名称')
|
|
grade = fields.IntField(null=True,choices=UserType, default=0, description='角色等级')
|
|
masks = fields.JSONField(description='柜子权限')
|
|
portion = fields.JSONField(description='中控权限')
|
|
comment = fields.TextField(null=True, description='角色描述')
|
|
created_at = fields.DatetimeField(auto_now_add=True)
|
|
updated_at = fields.DatetimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
table = 'roles'
|
|
table_description = '角色表'
|
|
|
|
def __str__(self):
|
|
return 'Role(id={0.id} name={0.name})'.format(self)
|
|
|
|
|
|
class ModuleMenu(models.Model):
|
|
id = fields.IntField(pk=True, description='pk')
|
|
name = fields.CharField(max_length=36, description='模块名称')
|
|
rank = fields.IntField(description='排序')
|
|
options = fields.JSONField(description='选项')
|
|
alias = fields.JSONField(null=True, description='别名', default="[]")
|
|
|
|
class Meta:
|
|
table = 'module_menu'
|
|
table_description = '模块菜单表'
|