19 lines
608 B
Python
19 lines
608 B
Python
from fastapi import APIRouter, Depends
|
|
from fastapi.security import OAuth2PasswordRequestForm
|
|
from sqlalchemy.orm import Session
|
|
|
|
from config.database import get_db
|
|
from schemas.session import SessionResponse
|
|
from service import session_service
|
|
|
|
router = APIRouter(
|
|
prefix="/session",
|
|
tags=["会话"],
|
|
responses={404: {"description": "Not found"}}
|
|
)
|
|
|
|
|
|
@router.post("", summary="创建会话", response_model=SessionResponse)
|
|
def create(form_data: OAuth2PasswordRequestForm = Depends(), db: Session = Depends(get_db)):
|
|
return session_service.create(db, form_data.username, form_data.password)
|