Move schemas for Item, Tag, and Trip creation
This commit is contained in:
parent
708dc0e96d
commit
d5897f8618
2 changed files with 22 additions and 19 deletions
|
|
@ -1,9 +1,7 @@
|
||||||
from datetime import date
|
|
||||||
from typing import List
|
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
from fastapi import Depends, FastAPI
|
from fastapi import Depends, FastAPI
|
||||||
from pydantic import BaseModel
|
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
from backend.schemas import ItemCreate
|
||||||
from models import Base, Item, Tag
|
from models import Base, Item, Tag
|
||||||
from database import engine, get_db
|
from database import engine, get_db
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
@ -24,22 +22,6 @@ async def startup():
|
||||||
def read_root():
|
def read_root():
|
||||||
return {"status": "running"}
|
return {"status": "running"}
|
||||||
|
|
||||||
class TagCreate(BaseModel):
|
|
||||||
name: str
|
|
||||||
|
|
||||||
|
|
||||||
class ItemCreate(BaseModel):
|
|
||||||
name: str
|
|
||||||
tag_names: List[str]
|
|
||||||
|
|
||||||
|
|
||||||
class TripCreate(BaseModel):
|
|
||||||
name: str
|
|
||||||
start_date: date
|
|
||||||
end_date: date
|
|
||||||
selected_tags: List[str]
|
|
||||||
marked_tags: List[str]
|
|
||||||
|
|
||||||
@app.post("/items/")
|
@app.post("/items/")
|
||||||
async def create_item(item: ItemCreate, db: AsyncSession = Depends(get_db)):
|
async def create_item(item: ItemCreate, db: AsyncSession = Depends(get_db)):
|
||||||
user_id = FIXED_USER_ID
|
user_id = FIXED_USER_ID
|
||||||
|
|
|
||||||
21
backend/schemas.py
Normal file
21
backend/schemas.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
from datetime import date
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class TagCreate(BaseModel):
|
||||||
|
name: str
|
||||||
|
|
||||||
|
|
||||||
|
class ItemCreate(BaseModel):
|
||||||
|
name: str
|
||||||
|
tag_names: List[str]
|
||||||
|
|
||||||
|
|
||||||
|
class TripCreate(BaseModel):
|
||||||
|
name: str
|
||||||
|
start_date: date
|
||||||
|
end_date: date
|
||||||
|
selected_tags: List[str]
|
||||||
|
marked_tags: List[str]
|
||||||
Loading…
Reference in a new issue