feat: Add 4 endpoints via editor

This commit is contained in:
Backend IM Bot 2025-04-17 16:23:47 +00:00
parent 55e7daf081
commit 89b7486e36
4 changed files with 75 additions and 0 deletions

20
endpoints/names.post.py Normal file
View File

@ -0,0 +1,20 @@
from fastapi import APIRouter, Depends, status, HTTPException
# TODO: Import db session, schemas, models as needed
# from pydantic import BaseModel # Example
router = APIRouter()
# TODO: Define request body schema if needed
# class name_Create(BaseModel):
# name: str # Example field
@router.post("/names", status_code=status.HTTP_201_CREATED)
async def create_name(
# item: name_Create, # Example request body
# db: Session = Depends(get_db) # Example dependency
):
"""first rest: Create new item"""
# TODO: Implement logic to create a new name
print(f"Creating new name") # with data: {item.dict()}")
return {"message": "name created successfully"} # Placeholder

View File

@ -0,0 +1,15 @@
from fastapi import APIRouter, Depends, HTTPException, status
router = APIRouter()
@router.delete("/names/{name_id}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_name_item(
name_id: Any, # TODO: Adjust type hint
# db: Session = Depends(get_db) # Example dependency
):
"""first rest: Delete item by ID"""
# TODO: Implement logic to delete name with id: {name_id}
print(f"Deleting name with id: {name_id}")
# Example: Check if found, perform deletion, raise 404 if not
return None # Return No Content on success

View File

@ -0,0 +1,18 @@
from fastapi import APIRouter, Depends, HTTPException, status
# TODO: Import db session, schemas, models as needed
router = APIRouter()
@router.get("/names/{name_id}")
async def get_name_item(
name_id: Any, # TODO: Adjust type hint (e.g., int, str, UUID)
# db: Session = Depends(get_db) # Example dependency
):
"""first rest: Get item by ID"""
# TODO: Implement logic to fetch name with id: {name_id}
print(f"Fetching name with id: {name_id}")
# Example: Check if found, raise 404 if not
# if not found:
# raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="name not found")
return {"name_id": name_id} # Placeholder

View File

@ -0,0 +1,22 @@
from fastapi import APIRouter, Depends, HTTPException, status
# TODO: Import db session, schemas, models as needed
# from pydantic import BaseModel # Example
router = APIRouter()
# TODO: Define request body schema if needed
# class name_Update(BaseModel):
# name: str # Example field
@router.put("/names/{name_id}")
async def update_name_item(
name_id: Any, # TODO: Adjust type hint
# item: name_Update, # Example request body
# db: Session = Depends(get_db) # Example dependency
):
"""first rest: Update item by ID"""
# TODO: Implement logic to update name with id: {name_id}
print(f"Updating name with id: {name_id}") # with data: {item.dict()}")
# Example: Check if found, raise 404 if not
return {"message": "name updated successfully"} # Placeholder