Spaces:
Build error
Build error
File size: 1,446 Bytes
b7a7f32 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
from typing import Any, List
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from utils import deps
from cruds import crud_user_permission
from schemas.user_permission import (
UserPermission,
UserPermissionCreate,
UserPermissionUpdate,
)
router = APIRouter()
@router.get("/", response_model=List[UserPermission])
async def get_user_permission(
db: Session = Depends(deps.get_db), skip: int = 0, limit: int = 100
) -> Any:
user_permission = crud_user_permission.get_multi(db, skip=skip, limit=limit)
return user_permission
@router.post("/", response_model=UserPermission)
async def create_user_permission(
db: Session = Depends(deps.get_db), *, obj_in: UserPermissionCreate
) -> Any:
user_permission = crud_user_permission.create(db, obj_in=obj_in)
return user_permission
@router.get("/{id}", response_model=UserPermission)
async def get_specific_user_permission(
db: Session = Depends(deps.get_db), *, id: int
) -> Any:
user_permission = crud_user_permission.get(db, id)
return user_permission
@router.put("/{id}", response_model=UserPermission)
async def update_user_permission(
db: Session = Depends(deps.get_db), *, id: int, obj_in: UserPermissionUpdate
) -> Any:
user_permission = crud_user_permission.get(db, id)
user_permission = crud_user_permission.update(
db, db_obj=user_permission, obj_in=obj_in
)
return user_permission
|