Merge branch 'master' into VORKOUT-7

This commit is contained in:
TheNoxium
2025-06-05 13:04:25 +05:00
34 changed files with 909 additions and 322 deletions

View File

@@ -28,7 +28,6 @@ api_router = APIRouter(
tags=["User accountModel"],
)
@api_router.get("",response_model=AllUserResponse)
async def get_all_account(
@@ -87,33 +86,23 @@ async def create_account(
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="An account with this information already exists.")
status_code=status.HTTP_400_BAD_REQUEST, detail="An account with this information already exists."
)
@api_router.put("/{user_id}", response_model=User)
async def update_account(
user_id: int,
request: Request,
user_update: UserUpdate,
connection: AsyncConnection = Depends(get_connection_dep)
):
user_id: int, request: Request, user_update: UserUpdate, connection: AsyncConnection = Depends(get_connection_dep)
):
current_user = request.state.current_user
authorize_user = await db_user_role_validation(connection, current_user)
user = await get_user_by_id(connection, user_id)
if user is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Account not found")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Account not found")
update_values = update_user_data_changes(user_update,user)
update_values = update_user_data_changes(user_update, user)
if update_values is None:
return user
@@ -139,17 +128,13 @@ async def delete_account(
authorize_user = await db_user_role_validation(connection, current_user)
user = await get_user_by_id(connection, user_id)
if user is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Account not found")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Account not found")
user_update = UserUpdate(status=AccountStatus.DELETED.value)
update_values = update_user_data_changes(user_update,user)
update_values = update_user_data_changes(user_update, user)
if update_values is None:
return user