from pydantic import BaseModel from typing import Annotated, Union from datetime import date from typing import List from fastapi import UploadFile, Form class Book(BaseModel): id: int class DelAnnouncement(BaseModel): id: int class Announcement(BaseModel): id: int user_id: int name: str category: str best_by: date address: str longtitude: float latitude: float description: str # src: Union[UploadFile, None] = None #изображение продукта в объявлении src: Union[str, None] = None #изображение продукта в объявлении metro: str #ближайщее метро от адреса нахождения продукта trashId: Union[int, None] = None booked_by: Union[int, None] = 0 #статус бронирования (либо 0, либо айди бронирующего) class Config: orm_mode = True arbitrary_types_allowed=True class PutAnnInDB(BaseModel): name: Annotated[str, Form()] category: Annotated[str, Form()] best_by: Annotated[date, Form()] address: Annotated[str, Form()] longtitude: Annotated[float, Form()] latitude: Annotated[float, Form()] description: Annotated[str, Form()] src: Annotated[Union[UploadFile, None], Form()] = None #изображение продукта в объявлении metro: Annotated[str, Form()] #ближайщее метро от адреса нахождения продукта class Token(BaseModel): access_token: str # token_type: str class TokenData(BaseModel): user_id: Union[int, None] = None class User(BaseModel): id: int nickname: str name: Union[str, None] = None surname: Union[str, None] = None disabled: Union[bool, None] = False items: list[Announcement] = [] class Config: orm_mode = True arbitrary_types_allowed=True class UserInDB(User): hashed_password: str class Poem(BaseModel): title: str text: str author: str class TrashboxBase(BaseModel): Name: str Lat: float Lng: float class TrashboxResponse(TrashboxBase): Address: str Categories: List[str] class TrashboxRequest(TrashboxBase): Category: str class DisposeRequest(BaseModel): ann_id: int trashbox: TrashboxRequest class SortAnnouncements(BaseModel): obsolete: Union[int, None] = False user_id: Union[int, None] = None metro: Union[str, None] = None category: Union[str, None] = None # booked_by: Union[int, None] = None class DisposeData(BaseModel): ann_id: int # id объявления trash_id: int # id мусорки trash_category: str # категория мусора # схема для начисления баллов class AddPoints(BaseModel): user_id: int rate: int