feat: clinic offer api
This commit is contained in:
+56
-1
@@ -3,8 +3,9 @@ from fastapi import APIRouter, Request
|
||||
from services.clinicServices import ClinicServices
|
||||
from schemas.UpdateSchemas import ClinicStatusUpdate
|
||||
from schemas.ApiResponse import ApiResponse
|
||||
from schemas.BaseSchemas import CreateSuperAdmin, ResetPasswordBase
|
||||
from schemas.BaseSchemas import CreateSuperAdmin, MasterAppointmentTypeBase, ClinicOffersBase
|
||||
from services.authService import AuthService
|
||||
from services.masterAppointmentServices import MasterAppointmentServices
|
||||
from utils.constants import DEFAULT_LIMIT, DEFAULT_PAGE
|
||||
|
||||
router = APIRouter()
|
||||
@@ -29,3 +30,57 @@ def get_users(req:Request, limit:int = DEFAULT_LIMIT, page:int = DEFAULT_PAGE, s
|
||||
offset = (page - 1) * limit
|
||||
users = AuthService().get_admins(req.state.user, limit, offset, search)
|
||||
return ApiResponse(data=users, message="Users retrieved successfully")
|
||||
|
||||
@router.post("/master-data")
|
||||
def create_master_data(appointment_type: MasterAppointmentTypeBase):
|
||||
MasterAppointmentServices().create_master_appointment_type(appointment_type)
|
||||
return ApiResponse(data="OK", message="Master data created successfully")
|
||||
|
||||
|
||||
@router.get("/master-data")
|
||||
def get_master_data():
|
||||
appointment_types = MasterAppointmentServices().get_master_appointment_types()
|
||||
return ApiResponse(data=appointment_types, message="Master data retrieved successfully")
|
||||
|
||||
|
||||
|
||||
@router.get("/clinic/offers")
|
||||
async def get_clinic_offers(
|
||||
req:Request,
|
||||
page: int = DEFAULT_PAGE,
|
||||
limit: int = DEFAULT_LIMIT,
|
||||
search:str = ""
|
||||
):
|
||||
if page < 1:
|
||||
page = 1
|
||||
offset = (page - 1) * limit
|
||||
|
||||
clinic_offers = ClinicServices().get_clinic_offers(req.state.user, limit, offset, search)
|
||||
return ApiResponse(data=clinic_offers, message="Clinic offers retrieved successfully")
|
||||
|
||||
|
||||
@router.post("/clinic/offer")
|
||||
async def create_clinic_offer(
|
||||
req:Request,
|
||||
clinic_offer: ClinicOffersBase
|
||||
):
|
||||
ClinicServices().create_clinic_offer(req.state.user, clinic_offer)
|
||||
return ApiResponse(data="OK", message="Clinic offer created successfully")
|
||||
|
||||
@router.put("/clinic/offer/{clinic_offer_id}")
|
||||
async def update_clinic_offer(
|
||||
req:Request,
|
||||
clinic_offer_id: int,
|
||||
clinic_offer: ClinicOffersBase
|
||||
):
|
||||
ClinicServices().update_clinic_offer(req.state.user, clinic_offer_id, clinic_offer)
|
||||
return ApiResponse(data="OK", message="Clinic offer updated successfully")
|
||||
|
||||
@router.delete("/clinic/offer/{clinic_offer_id}")
|
||||
async def delete_clinic_offer(
|
||||
req:Request,
|
||||
clinic_offer_id: int
|
||||
):
|
||||
ClinicServices().delete_clinic_offer(req.state.user, clinic_offer_id)
|
||||
return ApiResponse(data="OK", message="Clinic offer deleted successfully")
|
||||
|
||||
@@ -11,6 +11,7 @@ from services.clinicServices import ClinicServices
|
||||
# Constants
|
||||
from schemas.ApiResponse import ApiResponse
|
||||
from interface.common_response import CommonResponse
|
||||
from schemas.BaseSchemas import ClinicOffersBase
|
||||
from utils.constants import DEFAULT_PAGE, DEFAULT_SKIP, DEFAULT_LIMIT
|
||||
|
||||
router = APIRouter()
|
||||
@@ -51,4 +52,4 @@ async def update_clinic(
|
||||
@router.delete("/{clinic_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def delete_clinic(clinic_id: int):
|
||||
ClinicServices().delete_clinic(clinic_id)
|
||||
return ApiResponse(message="Clinic deleted successfully")
|
||||
return ApiResponse(data="OK", message="Clinic deleted successfully")
|
||||
|
||||
Reference in New Issue
Block a user