feat:增加权限控制
This commit is contained in:
18
api/session.py
Normal file
18
api/session.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user