feat: add user and admin page
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
28
backend/alembic/versions/a12a2ecd70b9_.py
Normal file
28
backend/alembic/versions/a12a2ecd70b9_.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: a12a2ecd70b9
|
||||
Revises: 96dff3d4cf1c
|
||||
Create Date: 2026-05-17 09:46:42.181807
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'a12a2ecd70b9'
|
||||
down_revision: Union[str, Sequence[str], None] = '96dff3d4cf1c'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
pass
|
||||
28
backend/alembic/versions/ab09ab5070f7_initial.py
Normal file
28
backend/alembic/versions/ab09ab5070f7_initial.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""initial
|
||||
|
||||
Revision ID: ab09ab5070f7
|
||||
Revises: a12a2ecd70b9
|
||||
Create Date: 2026-05-17 11:44:50.049279
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'ab09ab5070f7'
|
||||
down_revision: Union[str, Sequence[str], None] = 'a12a2ecd70b9'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
pass
|
||||
Binary file not shown.
@@ -5,6 +5,7 @@ from fastapi import HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
import schemas
|
||||
from schemas import ItemResponse
|
||||
from services import crud
|
||||
|
||||
from app.db.session import SessionLocal
|
||||
@@ -14,30 +15,26 @@ router = APIRouter()
|
||||
|
||||
|
||||
def get_db():
|
||||
|
||||
db = SessionLocal()
|
||||
|
||||
try:
|
||||
yield db
|
||||
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
# GET ALL ITEMS
|
||||
@router.get("/items", response_model=list[ItemResponse])
|
||||
def get_items(db: Session = Depends(get_db)):
|
||||
return crud.get_items(db)
|
||||
|
||||
|
||||
# CREATE ITEM
|
||||
@router.post(
|
||||
"/items",
|
||||
response_model=schemas.ItemResponse
|
||||
)
|
||||
@router.post("/items", response_model=ItemResponse)
|
||||
def create_item(
|
||||
item: schemas.ItemCreate,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
|
||||
return crud.create_item(
|
||||
db,
|
||||
item.title
|
||||
)
|
||||
return crud.create_item(db, item.title)
|
||||
|
||||
|
||||
# DELETE ITEM
|
||||
@@ -46,19 +43,7 @@ def delete_item(
|
||||
item_id: int,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
|
||||
item = crud.delete_item(
|
||||
db,
|
||||
item_id
|
||||
)
|
||||
|
||||
item = crud.delete_item(db, item_id)
|
||||
if not item:
|
||||
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail="Item not found"
|
||||
)
|
||||
|
||||
return {
|
||||
"message": "Item deleted"
|
||||
}
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
return {"message": "Item deleted"}
|
||||
Binary file not shown.
@@ -17,6 +17,5 @@ app.add_middleware(
|
||||
)
|
||||
|
||||
|
||||
app.include_router(admin_router)
|
||||
|
||||
app.include_router(user_router)
|
||||
app.include_router(admin_router, prefix="/admin")
|
||||
app.include_router(user_router, prefix="/user")
|
||||
BIN
backend/wheel.db
BIN
backend/wheel.db
Binary file not shown.
Reference in New Issue
Block a user