porridger/back/schemas.py

104 lines
2.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
reg_date: date
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 AddRating(BaseModel):
user_id: int
rate: int