login page
This commit is contained in:
4
backend/models/__init__.py
Normal file
4
backend/models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from models.menu import MenuModel
|
||||
from models.relation import RoleMenuModel, UserRoleModel
|
||||
from models.role import RoleModel
|
||||
from models.user import UserModel
|
25
backend/models/menu.py
Normal file
25
backend/models/menu.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from core.enums import MenuType
|
||||
from core.table import Table, fields
|
||||
|
||||
|
||||
class MenuModel(Table):
|
||||
"""
|
||||
菜单表
|
||||
"""
|
||||
|
||||
name = fields.CharField(max_length=20, description="名称", null=True)
|
||||
meta = fields.JSONField(description="元数据信息", null=True)
|
||||
path = fields.CharField(max_length=128, description="菜单url", null=True)
|
||||
type = fields.IntEnumField(MenuType, description="菜单类型")
|
||||
component = fields.CharField(max_length=128, description="组件地址", null=True)
|
||||
pid = fields.IntField(description="父id", null=True)
|
||||
identifier = fields.CharField(max_length=30, description="权限标识 user:add", null=True)
|
||||
api = fields.CharField(max_length=128, description="接口地址", null=True)
|
||||
method = fields.CharField(max_length=10, description="接口请求方式", null=True)
|
||||
regx = fields.CharField(max_length=50, description="接口地址正则表达式", null=True)
|
||||
|
||||
class Meta:
|
||||
table = "sys_menu"
|
||||
table_description = "菜单表"
|
||||
# 非唯一的索引
|
||||
indexes = ("type", "name")
|
25
backend/models/relation.py
Normal file
25
backend/models/relation.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from core.table import Table, fields
|
||||
|
||||
|
||||
class RoleRelationMixin:
|
||||
rid = fields.IntField(description="角色id")
|
||||
|
||||
|
||||
class UserRoleModel(Table, RoleRelationMixin):
|
||||
"""用户角色关系表"""
|
||||
|
||||
uid = fields.IntField(description="用户id")
|
||||
|
||||
class Meta:
|
||||
table = "sys_user_role"
|
||||
indexes = ("uid", "rid")
|
||||
|
||||
|
||||
class RoleMenuModel(Table, RoleRelationMixin):
|
||||
"""角色菜单(权限)关系表"""
|
||||
|
||||
mid = fields.IntField(description="菜单ID")
|
||||
|
||||
class Meta:
|
||||
table = "sys_role_menu"
|
||||
indexes = ("mid", "rid")
|
14
backend/models/role.py
Normal file
14
backend/models/role.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from core.table import Table, fields
|
||||
|
||||
|
||||
class RoleModel(Table):
|
||||
"""
|
||||
角色表
|
||||
"""
|
||||
|
||||
name = fields.CharField(max_length=20, description="角色名称")
|
||||
remark = fields.CharField(max_length=200, description="角色描述")
|
||||
|
||||
class Meta:
|
||||
table = "sys_role"
|
||||
table_description = "角色表"
|
19
backend/models/user.py
Normal file
19
backend/models/user.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from core.enums import UserType
|
||||
from core.table import Table, fields
|
||||
|
||||
|
||||
class UserModel(Table):
|
||||
"""
|
||||
用户模型类 > user table
|
||||
"""
|
||||
|
||||
username = fields.CharField(max_length=16, description="账号", unique=True)
|
||||
nickname = fields.CharField(max_length=20, description="姓名", null=True)
|
||||
password = fields.CharField(max_length=128, description="密码")
|
||||
|
||||
class Meta:
|
||||
table = "sys_user"
|
||||
table_description = "用户表"
|
||||
# 索引
|
||||
unique_together = ("username",)
|
||||
|
Reference in New Issue
Block a user