porridger/back/schemas.py

95 lines
2.1 KiB
Python

from pydantic import BaseModel
from typing import Annotated, Union
from datetime import date
from typing import List
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[str, None] = None #изображение продукта в объявлении
metro: str #ближайщее метро от адреса нахождения продукта
trashId: Union[int, None] = None
booked_by: int #статус бронирования (либо -1, либо айди бронирующего)
class Config:
orm_mode = True
arbitrary_types_allowed=True
class Token(BaseModel):
access_token: str
# token_type: str
class TokenData(BaseModel):
user_id: Union[int, None] = None
class User(BaseModel):
id: int
email: str
name: Union[str, None] = None
surname: str
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