fix: list api response
This commit is contained in:
@@ -6,6 +6,7 @@ from models import ClinicDoctors
|
||||
from sqlalchemy.orm import Session
|
||||
from services.clinicServices import ClinicServices
|
||||
from exceptions import ResourceNotFoundException
|
||||
from interface.common_response import CommonResponse
|
||||
|
||||
class ClinicDoctorsServices:
|
||||
def __init__(self):
|
||||
@@ -67,4 +68,13 @@ class ClinicDoctorsServices:
|
||||
result[status.value] = count
|
||||
|
||||
return result
|
||||
|
||||
def get_clinic_doctors(self):
|
||||
clinic_doctors = self.db.query(ClinicDoctors).all()
|
||||
|
||||
total = self.db.query(ClinicDoctors).count()
|
||||
|
||||
response = CommonResponse(data=[ClinicDoctorResponse(**clinic_doctor.__dict__.copy()) for clinic_doctor in clinic_doctors], total=total)
|
||||
|
||||
return response
|
||||
|
||||
@@ -9,6 +9,7 @@ from models import Clinics
|
||||
from enums.enums import ClinicStatus, UserType
|
||||
from schemas.UpdateSchemas import UserUpdate
|
||||
from exceptions.unauthorized_exception import UnauthorizedException
|
||||
from interface.common_response import CommonResponse
|
||||
from utils.password_utils import hash_password
|
||||
from schemas.CreateSchemas import UserCreate
|
||||
from exceptions.resource_not_found_exception import ResourceNotFoundException
|
||||
@@ -131,11 +132,14 @@ class UserServices:
|
||||
Users.userType.contains(search)
|
||||
)
|
||||
)
|
||||
users = query.limit(limit).offset(offset).all()
|
||||
|
||||
user_response = [UserResponse(**user.__dict__.copy()) for user in users]
|
||||
|
||||
return user_response
|
||||
users = query.limit(limit).offset(offset).all()
|
||||
|
||||
total = self.db.query(Users).count()
|
||||
|
||||
response = CommonResponse(data=[UserResponse(**user.__dict__.copy()) for user in users], total=total)
|
||||
|
||||
return response
|
||||
|
||||
async def get_user_by_email(self, email: str) -> UserResponse:
|
||||
user = self.db.query(Users).filter(Users.email == email.lower()).first()
|
||||
|
||||
Reference in New Issue
Block a user