Add project model, routes and logic. WIP
This commit is contained in:
parent
7a62ff58a3
commit
bbe0df9546
4 changed files with 76 additions and 1 deletions
29
app/routers/project_route.py
Normal file
29
app/routers/project_route.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from app.models.project import Project
|
||||
from fastapi import APIRouter
|
||||
from app.logic.project_logic import create, get_all, get_by_id, get_with_parent
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/projects",
|
||||
tags=["projects"]
|
||||
)
|
||||
|
||||
@router.get("/")
|
||||
def get_default():
|
||||
|
||||
return {
|
||||
"message": "Root for Projects API"
|
||||
}
|
||||
|
||||
@router.get("/all")
|
||||
def get_all_projects(parent: int | None = None):
|
||||
if parent:
|
||||
return get_with_parent(parent)
|
||||
return get_all()
|
||||
|
||||
@router.get("/project/{project_id}")
|
||||
def get_project_by_id(project_id: int):
|
||||
return get_by_id(project_id)
|
||||
|
||||
@router.post("/")
|
||||
def create_project(project: Project):
|
||||
return create(project)
|
||||
Loading…
Reference in a new issue