add count get
This commit is contained in:
parent
68c578c449
commit
76a4680622
@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from ..dependencies import users_token, permissions_checker, database
|
||||
from ..models import users
|
||||
from typing import Annotated
|
||||
@ -47,6 +48,14 @@ async def read_users_id(authorize: Annotated[bool, Depends(permissions_checker.P
|
||||
async def read_users_me(current_user: Annotated[users.User, Depends(users_token.get_current_active_user)], authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin", "User"]))]):
|
||||
return current_user
|
||||
|
||||
@router.get("/users/count", tags=["users"])
|
||||
async def read_users_count(authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))]):
|
||||
count = database.database.get_collection("users").estimated_document_count()
|
||||
content = {"count":count}
|
||||
response = JSONResponse(content=content)
|
||||
return response
|
||||
|
||||
|
||||
@router.get("/users/{item_id}", tags=["users"], response_model=users.User)
|
||||
async def read_users_id(item_id : str, authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))]):
|
||||
user_repository = users.UserRepository(database=database.database)
|
||||
@ -54,7 +63,6 @@ async def read_users_id(item_id : str, authorize: Annotated[bool, Depends(permis
|
||||
return user
|
||||
|
||||
|
||||
|
||||
@router.delete("/users/me",tags=["users"], response_model=users.User, response_model_exclude=["id", "password", "roles", "disabled"])
|
||||
async def read_users_me(current_user: Annotated[users.User, Depends(users_token.get_current_active_user)], authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin", "User"]))], remove: bool = False):
|
||||
user_repository = users.UserRepository(database=database.database)
|
||||
|
Loading…
x
Reference in New Issue
Block a user