from typing import Annotated, List from sqlalchemy.orm import Session from fastapi import APIRouter, Depends, HTTPException from app.db import get_db from app.core import schemas, crud from app.security import get_current_user router = APIRouter() @router.get("/get-all-prompts/", response_model=List[schemas.Prompt]) def get_all_prompts( db: Annotated[Session, Depends(get_db)], current_user: Annotated[schemas.User, Depends(get_current_user)], ): if not current_user.is_superuser: raise HTTPException(status_code=403, detail="Forbidden") return crud.get_all_prompts(db=db) @router.get("/get-prompt_by_user_id/{user_id}/", response_model=List[schemas.Prompt]) def get_prompt_by_user_id( user_id: int, db: Annotated[Session, Depends(get_db)], current_user: Annotated[schemas.User, Depends(get_current_user)], ): if not current_user.is_superuser: raise HTTPException(status_code=403, detail="Forbidden") return crud.get_prompt_by_user_id(user_id=user_id, db=db) # @router.post("/create-prompt/", response_model=schemas.Prompt) # def create_prompt( # prompt: str, # db: Annotated[Session, Depends(get_db)], # current_user: Annotated[schemas.User, Depends(get_current_user)], # ): # if not current_user.is_superuser: # raise HTTPException(status_code=403, detail="Forbidden") # return crud.create_prompt(prompt=prompt, db=db)