тесты
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
894 B

from fastapi import APIRouter
import backend_fastapi.schemas as schemas
from backend_fastapi.repositories import add_role, add_user, get_role_all, update_role, delete_role
from typing import List
router = APIRouter()
@router.post("/role")
async def create_role(role: schemas.RoleCreate) -> schemas.Role:
return await add_role(role)
@router.get("/role")
async def get_role() -> List[schemas.Role]:
return await get_role_all()
@router.patch("/role")
async def change_role(role: schemas.Role, id: int) -> None:
return await update_role(role, id)
@router.delete("/role")
async def remove_role(id: int) -> schemas.Role:
return await delete_role(id)
@router.post("/user")
async def create_user(user: schemas.UserCreate) -> schemas.User:
import hashlib
user.hashed_password = hashlib.sha256(user.hashed_password.encode('utf-8')).hexdigest()
return await add_user(user)