mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-18 06:42:51 +08:00

* WIP: add rbac authorization * Perform pre-commit fixes * add rbac route whitelist * add init test data user role associations * Restore database table id naming to fix generic crud base * Add database section value uniqueness settings * Update the test directory to tests * Update route_name file name to health_check * Split user auth and user action interfaces * Fix conflict between merge and current branch * Add pymysql dependencies * Fix RBAC authentication method * Add the select serialisation tool * Fix missing return messages due to global exception handler slicing * Update the user interface with associated relationships * Add items to be completed * Perform pre-commit fixes * Add pre-made routers * Paging data return structure optimisation * Split user auth and user interface tests * Fix user register test data structure error * Fix duplicate named test classes
51 lines
768 B
Python
51 lines
768 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from enum import Enum
|
|
|
|
|
|
class EnumBase(Enum):
|
|
@classmethod
|
|
def get_member_values(cls):
|
|
return [item.value for item in cls._member_map_.values()]
|
|
|
|
@classmethod
|
|
def get_member_names(cls):
|
|
return [name for name in cls._member_names_]
|
|
|
|
|
|
class IntEnum(int, EnumBase):
|
|
"""整型枚举"""
|
|
|
|
pass
|
|
|
|
|
|
class StrEnum(str, EnumBase):
|
|
"""字符串枚举"""
|
|
|
|
pass
|
|
|
|
|
|
class MenuType(IntEnum):
|
|
"""菜单类型"""
|
|
|
|
directory = 0
|
|
menu = 1
|
|
button = 2
|
|
|
|
|
|
class RoleDataScope(IntEnum):
|
|
"""数据范围"""
|
|
|
|
all = 1
|
|
custom = 2
|
|
|
|
|
|
class MethodType(StrEnum):
|
|
"""请求方法"""
|
|
|
|
GET = 'GET'
|
|
POST = 'POST'
|
|
PUT = 'PUT'
|
|
DELETE = 'DELETE'
|
|
PATCH = 'PATCH'
|