update
This commit is contained in:
parent
0871ef5c1c
commit
26a7d84f7d
@ -35,9 +35,7 @@ async def get_role(
|
||||
|
||||
|
||||
@router.post("/create", summary="创建角色")
|
||||
async def create_role(
|
||||
role_in: RoleCreate,
|
||||
):
|
||||
async def create_role(role_in: RoleCreate):
|
||||
if await role_controller.is_exist(name=role_in.name):
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
|
||||
@ -5,7 +5,7 @@ from app.models.enums import MethodType
|
||||
|
||||
class BaseApi(BaseModel):
|
||||
path: str = Field(..., description="API路径", example="/api/v1/user/list")
|
||||
summary: str = Field(None, description="API简介", example="查看用户列表")
|
||||
summary: str = Field("", description="API简介", example="查看用户列表")
|
||||
method: MethodType = Field(..., description="API方法", example="GET")
|
||||
tags: str = Field(..., description="API标签", example="User")
|
||||
|
||||
|
||||
@ -7,23 +7,23 @@ from pydantic import BaseModel, Field
|
||||
class BaseRole(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
desc: Optional[str]
|
||||
users: Optional[list]
|
||||
menus: Optional[list]
|
||||
apis: Optional[list]
|
||||
desc: str = ""
|
||||
users: Optional[list] = []
|
||||
menus: Optional[list] = []
|
||||
apis: Optional[list] = []
|
||||
created_at: Optional[datetime]
|
||||
updated_at: Optional[datetime]
|
||||
|
||||
|
||||
class RoleCreate(BaseModel):
|
||||
name: str = Field(example="管理员")
|
||||
desc: Optional[str] = Field(example="管理员角色")
|
||||
desc: str = Field("", examples="管理员角色")
|
||||
|
||||
|
||||
class RoleUpdate(BaseModel):
|
||||
id: int = Field(example=1)
|
||||
name: Optional[str] = Field(example="管理员")
|
||||
desc: Optional[str] = Field(example="管理员角色")
|
||||
name: str = Field(example="管理员")
|
||||
desc: str = Field("", example="管理员角色")
|
||||
|
||||
def update_dict(self):
|
||||
return self.model_dump(exclude_unset=True, exclude={"id"})
|
||||
|
||||
@ -5,6 +5,6 @@ from app.settings.config import settings
|
||||
|
||||
|
||||
def create_access_token(*, data: JWTPayload):
|
||||
payload = data.dict().copy()
|
||||
payload = data.model_dump().copy()
|
||||
encoded_jwt = jwt.encode(payload, settings.SECRET_KEY, algorithm=settings.JWT_ALGORITHM)
|
||||
return encoded_jwt
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user