添加用户鉴权
This commit is contained in:
13
mini-program/app/schemas/auth.py
Normal file
13
mini-program/app/schemas/auth.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
username: str = Field(min_length=1, max_length=191)
|
||||
password: str = Field(min_length=1, max_length=128)
|
||||
|
||||
|
||||
class LoginResponse(BaseModel):
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
expires_in: int
|
||||
user_id: int
|
||||
@@ -5,7 +5,6 @@ from pydantic import BaseModel, Field, model_validator
|
||||
|
||||
|
||||
class MessageCreateRequest(BaseModel):
|
||||
sender_user_id: int = Field(gt=0)
|
||||
peer_user_id: int = Field(gt=0)
|
||||
client_msg_id: str = Field(min_length=1, max_length=64)
|
||||
content_type: int = Field(description="1-text 2-audio 3-image 4-json")
|
||||
@@ -16,9 +15,6 @@ class MessageCreateRequest(BaseModel):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_message_fields(self) -> "MessageCreateRequest":
|
||||
if self.sender_user_id == self.peer_user_id:
|
||||
raise ValueError("sender_user_id and peer_user_id cannot be the same")
|
||||
|
||||
if self.content_type not in {1, 2, 3, 4}:
|
||||
raise ValueError("content_type must be one of 1, 2, 3, 4")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user