d5705c3a28
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Co-authored-by: Thomas Peetz <thomas.peetz@cimt-ag.de> Reviewed-on: #98
30 lines
709 B
Python
30 lines
709 B
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from src.db.models.bookshelf import Book
|
|
|
|
|
|
class BookResponse(BaseModel):
|
|
id: str
|
|
created_date: datetime
|
|
last_modified_date: datetime
|
|
version: int
|
|
isbn: str
|
|
title: str
|
|
year: int
|
|
publisher_id: str
|
|
|
|
def to_response(book: Book) -> BookResponse:
|
|
response: BookResponse = BookResponse(
|
|
id=book.id,
|
|
created_date=book.created_date,
|
|
last_modified_date=book.last_modified_date,
|
|
version=book.version,
|
|
isbn=str(book.isbn),
|
|
title=str(book.title),
|
|
year=book.year,
|
|
publisher_id=str(book.publisher_id)
|
|
)
|
|
return response
|