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
64 lines
1.2 KiB
Python
64 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, HttpUrl, Field
|
|
|
|
from backend.app.schemas.dept import GetAllDept
|
|
from backend.app.schemas.role import GetAllRole
|
|
|
|
|
|
class Auth(BaseModel):
|
|
username: str
|
|
password: str
|
|
|
|
|
|
class CreateUser(Auth):
|
|
dept_id: int
|
|
roles: list[int]
|
|
nickname: str
|
|
email: str = Field(..., example='user@example.com')
|
|
|
|
|
|
class _UserInfoBase(BaseModel):
|
|
dept_id: int
|
|
username: str
|
|
nickname: str
|
|
email: str = Field(..., example='user@example.com')
|
|
phone: str | None = None
|
|
|
|
|
|
class UpdateUser(_UserInfoBase):
|
|
roles: list[int]
|
|
|
|
|
|
class Avatar(BaseModel):
|
|
url: HttpUrl = Field(..., description='头像 http 地址')
|
|
|
|
|
|
class GetUserInfoNoRelation(_UserInfoBase):
|
|
id: int
|
|
user_uuid: str
|
|
avatar: str | None = None
|
|
is_active: bool
|
|
is_superuser: bool
|
|
time_joined: datetime = None
|
|
last_login: datetime | None = None
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class GetUserInfo(GetUserInfoNoRelation):
|
|
dept: GetAllDept | None = None
|
|
roles: list[GetAllRole]
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class ResetPassword(BaseModel):
|
|
id: int
|
|
password1: str
|
|
password2: str
|