From 240993b7531ce48987f1b6d52e1a4096e893aecf Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 19 Mar 2025 12:59:59 +0000 Subject: [PATCH] feat: Update endpoint books --- endpoints/books.post.py | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/endpoints/books.post.py b/endpoints/books.post.py index e69de29..63fd529 100644 --- a/endpoints/books.post.py +++ b/endpoints/books.post.py @@ -0,0 +1,43 @@ +from fastapi import APIRouter, Depends, HTTPException +from core.database import fake_users_db +import uuid + +router = APIRouter() + +@router.post("/gdt-book") +async def create_gdt_book( + title: str, + author: str, + description: str = "", + category: str = "general" +): + """Create a new GDT book entry""" + book_id = str(uuid.uuid4()) + + if title.strip() == "": + raise HTTPException(status_code=400, detail="Title cannot be empty") + + new_book = { + "id": book_id, + "title": title, + "author": author, + "description": description, + "category": category, + "created_at": "2024-01-01T00:00:00Z", # Demo timestamp + "status": "active" + } + + # Store in demo database + if "books" not in fake_users_db: + fake_users_db["books"] = {} + fake_users_db["books"][book_id] = new_book + + return { + "message": "GDT book created successfully", + "book_id": book_id, + "data": new_book, + "metadata": { + "created_timestamp": "2024-01-01T00:00:00Z", + "version": "1.0" + } + } \ No newline at end of file