@ -97,10 +97,7 @@ import lombok.AllArgsConstructor;
/ / @RestController
/ / @RequestMapping ( "/admin/api" )
@Tag (
name = "CRUD REST APIs for Admin in CommunityHall" ,
description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details"
)
@Tag ( name = "CRUD REST APIs for Admin in CommunityHall" , description = "CRUD REST APIs in CommunityHall to CREATE, UPDATE, FETCH AND DELETE Booking details" )
@RestController
@RequestMapping ( "/victoriahallbooking/admin/api" )
@AllArgsConstructor
@ -168,32 +165,10 @@ public class AdminAPIController {
@Autowired
private ApplicationLogsRepository applicationLogsRepository ;
@Operation (
summary = "Update HallDetails REST API" ,
description = "REST API to update the Hall Details"
)
@Operation ( summary = "Update HallDetails REST API" , description = "REST API to update the Hall Details" )
@ApiResponses ( {
@ApiResponse (
responseCode = "200" ,
description = "HTTP Status UPDATED" ,
content = @Content (
mediaType = "text/plain" ,
schema = @Schema ( implementation = HallDetails . class ) ,
examples = @ExampleObject ( value = "Hall details updated successfully" )
)
) ,
@ApiResponse (
responseCode = "500" ,
description = "HTTP Status Internal Server Error" ,
content = @Content (
mediaType = "application/json" ,
schema = @Schema ( implementation = ErrorResponseDto . class ) ,
examples = @ExampleObject (
name = "Internal Server Error Example" ,
value = "{ \"path\": \"/updateHallDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }"
)
)
)
@ApiResponse ( responseCode = "200" , description = "HTTP Status UPDATED" , content = @Content ( mediaType = "text/plain" , schema = @Schema ( implementation = HallDetails . class ) , examples = @ExampleObject ( value = "Hall details updated successfully" ) ) ) ,
@ApiResponse ( responseCode = "500" , description = "HTTP Status Internal Server Error" , content = @Content ( mediaType = "application/json" , schema = @Schema ( implementation = ErrorResponseDto . class ) , examples = @ExampleObject ( name = "Internal Server Error Example" , value = "{ \"path\": \"/updateHallDetails\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }" ) ) )
} )
@PostMapping ( "/updateHallDetails" )
public ResponseEntity < String > updateHallInfo (
@ -270,43 +245,18 @@ public class AdminAPIController {
return ResponseEntity . ok ( "Success" ) ;
}
@Operation (
summary = "Update Settlement Status REST API" ,
description = "REST API to update the Settlement Status to INITIATED"
)
@Operation ( summary = "Update Settlement Status REST API" , description = "REST API to update the Settlement Status to INITIATED" )
@ApiResponses ( {
@ApiResponse (
responseCode = "200" ,
description = "HTTP Status UPDATED" ,
content = @Content (
mediaType = "application/json" ,
schema = @Schema ( implementation = Settlement . class ) ,
examples = @ExampleObject (
name = "Settlement Example" ,
value = "{\"settlementId\": Id, \"Refundstatus\": \"INITIATED\", \"comments\": \"Settlement initiated successfully\"}"
)
)
) ,
@ApiResponse (
responseCode = "500" ,
description = "HTTP Status Internal Server Error" ,
content = @Content (
mediaType = "application/json" ,
schema = @Schema ( implementation = ErrorResponseDto . class ) ,
examples = @ExampleObject (
name = "Internal Server Error Example" ,
value = "{ \"path\": \"/updateInitiatedSettlementStatus/{settlementId}\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }"
)
)
)
@ApiResponse ( responseCode = "200" , description = "HTTP Status UPDATED" , content = @Content ( mediaType = "application/json" , schema = @Schema ( implementation = Settlement . class ) , examples = @ExampleObject ( name = "Settlement Example" , value = "{\"settlementId\": Id, \"Refundstatus\": \"INITIATED\", \"comments\": \"Settlement initiated successfully\"}" ) ) ) ,
@ApiResponse ( responseCode = "500" , description = "HTTP Status Internal Server Error" , content = @Content ( mediaType = "application/json" , schema = @Schema ( implementation = ErrorResponseDto . class ) , examples = @ExampleObject ( name = "Internal Server Error Example" , value = "{ \"path\": \"/updateInitiatedSettlementStatus/{settlementId}\", \"status\": 500, \"error\": \"Internal Server Error\", \"timestamp\": \"2024-06-22T05:47:04.347+00:00\" }" ) ) )
} )
@PostMapping ( "/updateInitiatedSettlementStatus/{settlementId}" )
public ResponseEntity < Settlement > updateInitiatedSettlementStatus (
@PathVariable ( "settlementId" ) int settlementId ,
@RequestParam ( "status" ) BookingDetails . RefundStatus status ,
@RequestParam ( "comments" ) String comments ) {
Settlement updateInitialiseSettlement = settlementService . updateSettlementStatus ( settlementId , status , comments ) ;
Settlement updateInitialiseSettlement = settlementService . updateSettlementStatus ( settlementId , status ,
comments ) ;
String adminname = ( String ) session . getAttribute ( "usertype" ) ;
Integer loginid = ( Integer ) session . getAttribute ( "id" ) ;
ApplicationLogs logs = new ApplicationLogs ( ) ;
@ -330,27 +280,11 @@ public class AdminAPIController {
}
}
@Operation (
summary = "HallDetails by HallId REST API" ,
description = "REST API to Retrieving the Hall Details by hallId"
)
@Operation ( summary = "HallDetails by HallId REST API" , description = "REST API to Retrieving the Hall Details by hallId" )
@ApiResponses ( {
@ApiResponse (
responseCode = "200" ,
description = "HTTP Status OK" ,
content = @Content (
mediaType = "application/json" ,
schema = @Schema ( implementation = HallDetails . class )
)
) ,
@ApiResponse (
responseCode = "400" ,
description = "Bad Request"
) ,
@ApiResponse (
responseCode = "404" ,
description = "Not Found"
)
@ApiResponse ( responseCode = "200" , description = "HTTP Status OK" , content = @Content ( mediaType = "application/json" , schema = @Schema ( implementation = HallDetails . class ) ) ) ,
@ApiResponse ( responseCode = "400" , description = "Bad Request" ) ,
@ApiResponse ( responseCode = "404" , description = "Not Found" )
} )
@GetMapping ( "/getHallDetails/{hallId}" )
public ResponseEntity < HallDetails > getHallDetails ( @PathVariable String hallId ) {
@ -370,10 +304,7 @@ public class AdminAPIController {
}
}
@Operation (
summary = "Saving the DiscountRange REST API" ,
description = "REST API to Saving the Discount Range for usertypes"
)
@Operation ( summary = "Saving the DiscountRange REST API" , description = "REST API to Saving the Discount Range for usertypes" )
@PostMapping ( "/savediscountrange" )
public String saveDiscountrange (
@RequestParam String userType ,
@ -427,12 +358,10 @@ public class AdminAPIController {
return "success" ;
}
@Operation (
summary = " Update the DiscountRange REST API" ,
description = "REST API to Updating the Discount Range for usertypes"
)
@Operation ( summary = " Update the DiscountRange REST API" , description = "REST API to Updating the Discount Range for usertypes" )
@PutMapping ( "/updateById/{id}" )
public String updateDiscountRangeById ( @PathVariable int id , @RequestParam float discountRange , HttpSession session ) {
public String updateDiscountRangeById ( @PathVariable int id , @RequestParam float discountRange ,
HttpSession session ) {
String adminname = ( String ) session . getAttribute ( "usertype" ) ;
Optional < DiscountRange > existingDiscount = discountRangeRepo . findById ( id ) ;
if ( existingDiscount . isPresent ( ) ) {
@ -462,11 +391,7 @@ public class AdminAPIController {
}
}
@Operation (
summary = " Delete the DiscountRange REST API" ,
description = "REST API to Deleting the Discount for usertypes"
)
@Operation ( summary = " Delete the DiscountRange REST API" , description = "REST API to Deleting the Discount for usertypes" )
@DeleteMapping ( "/deleteById/{id}" )
public ResponseEntity < String > deleteDiscountRangeById ( @PathVariable int id ) {
if ( discountRangeRepo . existsById ( id ) ) {
@ -523,10 +448,7 @@ public class AdminAPIController {
}
@Operation (
summary = "Retrieving the Discount Details REST API" ,
description = "REST API to Retrieve the Discount Details for usertypes"
)
@Operation ( summary = "Retrieving the Discount Details REST API" , description = "REST API to Retrieve the Discount Details for usertypes" )
/ / Retrieving the Discount Details
@GetMapping ( "/getDiscountDetails" )
public Optional < DiscountRange > getDIscountDetails ( @RequestParam ( "id" ) int id ) {
@ -534,54 +456,48 @@ public class AdminAPIController {
return discountdetails ;
}
@Operation (
summary = "Save Reasons REST API" ,
description = "REST API to save the reasons"
)
@Operation ( summary = "Save Reasons REST API" , description = "REST API to save the reasons" )
/ / saving the Reason
@PostMapping ( "/saveReason" )
public ResponseEntity < ? > saveReason ( @RequestBody ReasonMaster reasaon ) {
return ResponseEntity . ok ( reasonMasterService . saveTheReason ( reasaon ) ) ;
}
@Operation (
summary = "All Reasons REST API" ,
description = "REST API to retrie the allreasons"
)
@Operation ( summary = "All Reasons REST API" , description = "REST API to retrie the allreasons" )
/ / retrieving the allreasons
@GetMapping ( "/getReasons" )
@ResponseBody
public List < ReasonMaster > getAllReasons ( ) {
return reasonMasterService . getAllReasons ( ) ;
/ / return reasonMasterService . getAllReasons ( ) ;
return reasonMasterService . getAllReasonsWithStatus ( ) ;
}
@Operation (
summary = "Reason Documents by reasonId REST API" ,
description = "REST API to Get the ReasonDocuments By reasonId"
)
@Operation ( summary = "Reason Documents by reasonId REST API" , description = "REST API to Get the ReasonDocuments By reasonId" )
/ / Getting ReasonDocuments By reasonId
@GetMapping ( "/getReasonDocumentDetails" )
public List < ReasonDocumentMaster > getReasonDocumentDetails ( @RequestParam int reasonId ) {
return reasonMasterService . getReasonDocumentDetailsByReasonId ( reasonId ) ;
}
@Operation (
summary = "Booking Details by Fromdate,toDate and HallId REST API" ,
description = "REST API to get the Booking Details by Fromdate,toDate and HallId for GccBlokcing"
)
@Operation ( summary = "Booking Details by Fromdate,toDate and HallId REST API" , description = "REST API to get the Booking Details by Fromdate,toDate and HallId for GccBlokcing" )
/ / @GetMapping ( "/filter" )
/ / public ResponseEntity < List < BookingResponseDTO > > getFilteredBookings (
/ / @RequestParam ( "fromDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate fromDate ,
/ / @RequestParam ( "toDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate toDate ,
/ / @RequestParam ( "fromDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate
/ / fromDate ,
/ / @RequestParam ( "toDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate
/ / toDate ,
/ / @RequestParam ( "hallIds" ) List < Long > hallIds ) {
/ /
/ / List < BookingDetails > bookings = bookingService . getFilteredBookings ( fromDate , toDate , hallIds ) ;
/ / List < BookingDetails > bookings = bookingService . getFilteredBookings ( fromDate ,
/ / toDate , hallIds ) ;
/ /
/ / List < BookingResponseDTO > responses = new ArrayList < > ( ) ;
/ / for ( BookingDetails bookingDetails : bookings ) {
/ / / / Fetch GccBlockingDate records for each bookingId
/ / List < GccBlockingDate > gccBlockedList = blockingDateRepository . getByBookingId ( bookingDetails . getBookingId ( ) ) ;
/ / Integer blockingId = gccBlockedList . isEmpty ( ) ? null : gccBlockedList . get ( 0 ) . getBlockingId ( ) ;
/ / List < GccBlockingDate > gccBlockedList =
/ / blockingDateRepository . getByBookingId ( bookingDetails . getBookingId ( ) ) ;
/ / Integer blockingId = gccBlockedList . isEmpty ( ) ? null :
/ / gccBlockedList . get ( 0 ) . getBlockingId ( ) ;
/ / responses . add ( new BookingResponseDTO ( bookingDetails , blockingId ) ) ;
/ / }
/ /
@ -594,7 +510,8 @@ public class AdminAPIController {
@RequestParam ( "hallIds" ) List < Long > hallIds ) {
List < BookingDetails > bookings = bookingService . getFilteredBookings ( fromDate , toDate , hallIds ) ;
List < GccBlockingDate > gccBlockedList = blockingDateRepository . findByFromDateAndToDateBetweenAndHallIdIn ( fromDate , toDate , hallIds ) ;
List < GccBlockingDate > gccBlockedList = blockingDateRepository
. findByFromDateAndToDateBetweenAndHallIdIn ( fromDate , toDate , hallIds ) ;
Map < String , Object > response = new HashMap < > ( ) ;
response . put ( "bookings" , bookings ) ;
@ -603,22 +520,19 @@ public class AdminAPIController {
return ResponseEntity . ok ( response ) ;
}
@Operation (
summary = " GCC Blocked Booking Details REST API" ,
description = "REST API to get the GCC Blocked BookingDetails"
)
@Operation ( summary = " GCC Blocked Booking Details REST API" , description = "REST API to get the GCC Blocked BookingDetails" )
/ / retrieving the GCC Blocked BookingDetails
@GetMapping ( "/blockedevents" )
public ResponseEntity < List < GccBlockingDate > > getBlockedEvents (
@RequestParam ( "fromDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate fromDate ,
@RequestParam ( "toDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate toDate ,
@RequestParam ( "hallIds" ) List < Long > hallIds
) {
/ / System . out . println ( "Blocked Events Request - fromDate: " + fromDate + ", toDate: " + toDate + ", hallIds: " + hallIds ) ;
@RequestParam ( "hallIds" ) List < Long > hallIds ) {
/ / System . out . println ( "Blocked Events Request - fromDate: " + fromDate + " ,
/ / toDate : " + toDate + " , hallIds : " + hallIds ) ;
List < GccBlockingDate > blockedBookings = bookingService . getBlockedEvents ( fromDate , toDate , hallIds ) ;
/ / List < BookingDetails > bookingDetails = bookingService . getByBookingId ( fromDate , toDate , hallIds , blockingId , bookingId ) ;
/ / List < BookingDetails > bookingDetails =
/ / bookingService . getByBookingId ( fromDate , toDate , hallIds , blockingId , bookingId ) ;
if ( blockedBookings . isEmpty ( ) ) {
/ / System . out . println ( "No blocked bookings found." ) ;
@ -632,11 +546,7 @@ public class AdminAPIController {
return ResponseEntity . ok ( blockedBookings ) ;
}
@Operation (
summary = "UNBLOCK the gcc Blocked Event REST API" ,
description = "REST API to unblocking the Gcc blocked Events for blocking"
)
@Operation ( summary = "UNBLOCK the gcc Blocked Event REST API" , description = "REST API to unblocking the Gcc blocked Events for blocking" )
@GetMapping ( "/cancelByid" )
public ResponseEntity < String > cancellationById ( @RequestParam int blockingId ,
@RequestParam ( "fromDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate fromDate ,
@ -668,7 +578,8 @@ public class AdminAPIController {
List < BookingCalendar > bookingCalendars = bookingService . getBookedslots ( fromDate , endDate , hallIdList ) ;
if ( bookingCalendars . isEmpty ( ) ) {
return ResponseEntity . status ( HttpStatus . NOT_FOUND ) . body ( "No booking slots found for the given date range and hall IDs." ) ;
return ResponseEntity . status ( HttpStatus . NOT_FOUND )
. body ( "No booking slots found for the given date range and hall IDs." ) ;
}
/ / Iterate over bookingCalendars and update them as needed
@ -716,8 +627,10 @@ public class AdminAPIController {
/ / public ResponseEntity < String > cancellationById (
/ / @RequestParam int blockingId ,
/ / @RequestParam int bookingId ,
/ / @RequestParam ( "fromDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate fromDate ,
/ / @RequestParam ( "endDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate endDate ,
/ / @RequestParam ( "fromDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate
/ / fromDate ,
/ / @RequestParam ( "endDate" ) @DateTimeFormat ( pattern = "yyyy-MM-dd" ) LocalDate
/ / endDate ,
/ / @RequestParam ( value = "hallId" , required = false ) List < Long > hallId ) {
/ /
/ / System . out . println ( "Received blockingId: " + blockingId ) ;
@ -726,19 +639,23 @@ public class AdminAPIController {
/ / System . out . println ( "Received hallId: " + hallId ) ;
/ /
/ / / / Retrieve blocking date
/ / GccBlockingDate blockingDate = blockingDateRepository . findById ( blockingId ) . orElse ( null ) ;
/ / GccBlockingDate blockingDate =
/ / blockingDateRepository . findById ( blockingId ) . orElse ( null ) ;
/ /
/ / if ( blockingDate = = null ) {
/ / return ResponseEntity . status ( HttpStatus . NOT_FOUND ) . body ( "Blocking ID not found." ) ;
/ / return ResponseEntity . status ( HttpStatus . NOT_FOUND ) . body ( " Blocking ID not
/ / found . " ) ;
/ / }
/ /
/ / if ( hallId ! = null & & bookingId > 0 ) {
/ / / / Specific bookingId and hallId selected
/ /
/ / / / Retrieve and update booking calendar
/ / List < BookingCalendar > bookingCalendar = bookingService . getBookedslots ( fromDate , endDate , hallId ) ;
/ / List < BookingCalendar > bookingCalendar =
/ / bookingService . getBookedslots ( fromDate , endDate , hallId ) ;
/ / if ( bookingCalendar . isEmpty ( ) ) {
/ / return ResponseEntity . status ( HttpStatus . NOT_FOUND ) . body ( "No booking slots found for the given date and hall ID." ) ;
/ / return ResponseEntity . status ( HttpStatus . NOT_FOUND ) . body ( " No booking slots
/ / found for the given date and hall ID . " ) ;
/ / }
/ /
/ / BookingCalendar bookingSlots = bookingCalendar . get ( 0 ) ;
@ -752,7 +669,8 @@ public class AdminAPIController {
/ / hallIdList . remove ( hallId . toString ( ) ) ;
/ / String updatedHallIds = String . join ( "," , hallIdList ) ;
/ /
/ / List < String > bookingIdList = Arrays . asList ( blockingDate . getBookingIds ( ) . split ( "," ) ) ;
/ / List < String > bookingIdList =
/ / Arrays . asList ( blockingDate . getBookingIds ( ) . split ( "," ) ) ;
/ / bookingIdList . remove ( Integer . toString ( bookingId ) ) ;
/ / String updatedBookingIds = String . join ( "," , bookingIdList ) ;
/ /
@ -782,7 +700,8 @@ public class AdminAPIController {
/ / } else {
/ / / / All halls and bookings selected
/ / / / Retrieve and clear all bookings for the date range
/ / List < BookingCalendar > bookingCalendars = bookingService . getBookedslots ( fromDate , endDate , hallId ) ;
/ / List < BookingCalendar > bookingCalendars =
/ / bookingService . getBookedslots ( fromDate , endDate , hallId ) ;
/ / for ( BookingCalendar bookingCalendar : bookingCalendars ) {
/ / bookingCalendar . setBookingId_1 ( null ) ;
/ / bookingCalendar . setBookingId_2 ( null ) ;
@ -809,20 +728,14 @@ public class AdminAPIController {
/ / return ResponseEntity . ok ( "Success" ) ;
/ / }
@Operation (
summary = "HAll IMAGES by HallId REST API" ,
description = "REST API to get the hall Images by Hall Id"
)
@Operation ( summary = "HAll IMAGES by HallId REST API" , description = "REST API to get the hall Images by Hall Id" )
/ / retrieving Hall Images by Hallid
@GetMapping ( "/getImageById" )
public List < HallImages > getImageDetails ( @RequestParam int hallId ) {
return hallService . getHallImages ( hallId ) ;
}
@Operation (
summary = "GCC Blocking REST API" ,
description = "REST API to Block the Halls by Admin"
)
@Operation ( summary = "GCC Blocking REST API" , description = "REST API to Block the Halls by Admin" )
/ / GccBlocking Api
@PostMapping ( "/cancelAll" )
public ResponseEntity < String > cancelAllBookings (
@ -844,7 +757,8 @@ public class AdminAPIController {
. collect ( Collectors . toList ( ) ) ;
/ / Call the service with descriptions and documents
bookingService . cancelAllBookings ( fromDate , toDate , hallIdsList , reasonforblocking , selectedBookings , updatedBy , descriptions , documents ) ;
bookingService . cancelAllBookings ( fromDate , toDate , hallIdsList , reasonforblocking , selectedBookings , updatedBy ,
descriptions , documents ) ;
String adminname = ( String ) session . getAttribute ( "usertype" ) ;
Integer loginid = ( Integer ) session . getAttribute ( "id" ) ;
ApplicationLogs logs = new ApplicationLogs ( ) ;
@ -867,12 +781,15 @@ public class AdminAPIController {
/ / @PostMapping ( "/blockhall" )
/ / public ResponseEntity < String > blockHall (
/ / @RequestParam ( "blockingId" ) Integer blockingId ,
/ / @RequestParam ( "hallID" ) String hallID , / / Ensure this matches the parameter name used in AJAX
/ / @RequestParam ( value = "selectedBookings" , required = false ) List < String > selectedBookings ,
/ / @RequestParam ( "hallID" ) String hallID , / / Ensure this matches the parameter
/ / name used in AJAX
/ / @RequestParam ( value = "selectedBookings" , required = false ) List < String >
/ / selectedBookings ,
/ / HttpSession session ) {
/ /
/ / String updatedBy = ( String ) session . getAttribute ( "employeeId" ) ;
/ / Optional < GccBlockingDate > gccblocking = blockingDateRepository . findById ( blockingId ) ;
/ / Optional < GccBlockingDate > gccblocking =
/ / blockingDateRepository . findById ( blockingId ) ;
/ / GccBlockingDate gccblockingdata = gccblocking . get ( ) ;
/ /
/ / / / Convert startDate and endDate to String
@ -888,12 +805,13 @@ public class AdminAPIController {
/ / System . out . println ( "selected BookingIds: " + selectedBookings ) ;
/ /
/ / / / Pass the formatted date strings
/ / bookingService . cancelAllBookings ( startDateString , endDateString , hallIdsList , gccblockingdata . getDepartment ( ) , gccblockingdata . getBlockingReason ( ) , selectedBookings , updatedBy ) ;
/ / bookingService . cancelAllBookings ( startDateString , endDateString , hallIdsList ,
/ / gccblockingdata . getDepartment ( ) , gccblockingdata . getBlockingReason ( ) ,
/ / selectedBookings , updatedBy ) ;
/ /
/ / return ResponseEntity . ok ( "Success" ) ;
/ / }
@GetMapping ( "/bookingdetailsByuserId" )
public List < BookingDetails > getuserDetails ( @RequestParam Integer userId ) {
return bookingService . getAllBookingsByUserId ( userId ) ;
@ -901,11 +819,14 @@ public class AdminAPIController {
@GetMapping ( "/settlement-approved" )
public ResponseEntity < List < Settlement > > getApprovedSettlements ( HttpSession session ) {
List < Settlement > approvedSettlements = settlementRepository . findByBookingDetailsRefundStatus ( RefundStatus . APPROVED ) ;
List < Settlement > approvedSettlements = settlementRepository
. findByBookingDetailsRefundStatus ( RefundStatus . APPROVED ) ;
return ResponseEntity . ok ( approvedSettlements ) ;
}
/ / @PostMapping ( "/complete-refund" )
/ / public ResponseEntity < String > completeRefund ( @RequestBody List < String > bookingIds , HttpSession session , HttpServletResponse response ) throws IOException {
/ / public ResponseEntity < String > completeRefund ( @RequestBody List < String >
/ / bookingIds , HttpSession session , HttpServletResponse response ) throws
/ / IOException {
/ / String token = ( String ) session . getAttribute ( "jwtToken" ) ;
/ / / / System . out . println ( "tokensssssssss" + token ) ;
/ /
@ -919,28 +840,34 @@ public class AdminAPIController {
/ /
/ / if ( ! bookids . isEmpty ( ) ) {
/ / / / Prepare and return error response if there are errors
/ / StringBuilder errorResponse = new StringBuilder ( "Errors processing refund for IDs: " ) ;
/ / StringBuilder errorResponse = new StringBuilder ( " Errors processing refund for
/ / IDs : " ) ;
/ / for ( String bookId : bookids ) {
/ / errorResponse . append ( bookId ) . append ( ", " ) ;
/ / }
/ / return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( errorResponse . toString ( ) ) ;
/ / return
/ / ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( errorResponse . toString ( ) ) ;
/ / }
/ /
/ / return ResponseEntity . ok ( "Refund completed successfully" ) ;
/ / } catch ( Exception e ) {
/ / e . printStackTrace ( ) ;
/ / return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( "Error processing refund: " + e . getMessage ( ) ) ;
/ / return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( " Error
/ / processing refund : " + e . getMessage ( ) ) ;
/ / }
/ / } else {
/ / / / Token is invalid or not present , redirect to login
/ / session . invalidate ( ) ; / / Invalidate the session to clear all session attributes
/ / session . invalidate ( ) ; / / Invalidate the session to clear all session
/ / attributes
/ / response . sendRedirect ( "/login" ) ; / / Redirect to the login page
/ / return ResponseEntity . status ( HttpStatus . UNAUTHORIZED ) . build ( ) ; / / Return HTTP 401 Unauthorized
/ / return ResponseEntity . status ( HttpStatus . UNAUTHORIZED ) . build ( ) ; / / Return HTTP
/ / 401 Unauthorized
/ / }
/ / }
/ / @GetMapping ( "/Gccblocking" )
/ / public ResponseEntity < List < Object > > getGccBlockingEvents ( @RequestParam ( "hallId" ) int hallId ) {
/ / public ResponseEntity < List < Object > >
/ / getGccBlockingEvents ( @RequestParam ( "hallId" ) int hallId ) {
/ / System . out . println ( "Received hallId: " + hallId ) ;
/ /
/ / List < Object > results = bookingService . getGccBlockingEvents ( hallId ) ;
@ -992,8 +919,10 @@ public class AdminAPIController {
if ( hallDetailsOpt . isPresent ( ) ) {
HallDetails hallDetails = hallDetailsOpt . get ( ) ;
List < Integer > bookingIds = bookingDetailsRepository . findBookingIdsByHallIdAndBookingDateBetween ( hallId , startDate , endDate ) ;
/ / System . out . println ( "Booking IDs for hallId " + hallId + ": " + bookingIds ) ; / / Add this line
List < Integer > bookingIds = bookingDetailsRepository . findBookingIdsByHallIdAndBookingDateBetween ( hallId ,
startDate , endDate ) ;
/ / System . out . println ( "Booking IDs for hallId " + hallId + ": " + bookingIds ) ;
/ / / / Add this line
Map < String , Object > hallInfo = new HashMap < > ( ) ;
hallInfo . put ( "hallName" , hallDetails . getHallName ( ) ) ;
@ -1023,7 +952,6 @@ public class AdminAPIController {
}
}
@GetMapping ( "/blockedHallsByHallIdAndReason" )
@ResponseBody
public Map < String , Object > viewBlockedHallsByHallIdAndReason (
@ -1032,11 +960,13 @@ public class AdminAPIController {
@RequestParam @DateTimeFormat ( iso = DateTimeFormat . ISO . DATE_TIME ) Date startDate ,
@RequestParam @DateTimeFormat ( iso = DateTimeFormat . ISO . DATE_TIME ) Date endDate ) {
List < GccBlockingDate > blockedHalls = blockingDateRepository . findByBlockingReasonAndDateRange ( blockingReason , startDate , endDate ) ;
List < GccBlockingDate > blockedHalls = blockingDateRepository . findByBlockingReasonAndDateRange ( blockingReason ,
startDate , endDate ) ;
/ / Ensure distinct by hallId and other keys
List < GccBlockingDate > uniqueGccBlockingDates = blockedHalls . stream ( )
. filter ( distinctByKey ( g - > Arrays . asList ( g . getHallId ( ) , g . getBlockingReason ( ) , g . getStartDate ( ) , g . getEndDate ( ) ) ) )
. filter ( distinctByKey (
g - > Arrays . asList ( g . getHallId ( ) , g . getBlockingReason ( ) , g . getStartDate ( ) , g . getEndDate ( ) ) ) )
. collect ( Collectors . toList ( ) ) ;
/ / Prepare response data
@ -1083,7 +1013,6 @@ public class AdminAPIController {
return response ;
}
/ / Utility method to ensure distinct by a key
private static < T > Predicate < T > distinctByKey ( Function < ? super T , ? > keyExtractor ) {
Set < Object > seen = new HashSet < > ( ) ;
@ -1092,7 +1021,8 @@ public class AdminAPIController {
/ / Method to calculate number of bookings
private int calculateBookings ( HallDetails hall , GccBlockingDate blockedHall ) {
return blockingDateRepository . countBlockedBookings ( hall . getHallId ( ) , blockedHall . getStartDate ( ) , blockedHall . getEndDate ( ) ) ;
return blockingDateRepository . countBlockedBookings ( hall . getHallId ( ) , blockedHall . getStartDate ( ) ,
blockedHall . getEndDate ( ) ) ;
}
private double calculateRefund ( HallDetails hall , GccBlockingDate blockedHall ) {
@ -1111,7 +1041,8 @@ public class AdminAPIController {
@RequestParam ( required = false , defaultValue = "ALL" ) String userType ) {
try {
Map < String , Map < String , Integer > > statistics = bookingService . getBookingStatistics ( fromDate , toDate , zone , division , hallid , userType ) ;
Map < String , Map < String , Integer > > statistics = bookingService . getBookingStatistics ( fromDate , toDate , zone ,
division , hallid , userType ) ;
return ResponseEntity . ok ( statistics ) ;
} catch ( Exception e ) {
/ / Log the exception and return an appropriate error response
@ -1161,7 +1092,8 @@ public class AdminAPIController {
} catch ( IllegalArgumentException e ) {
return ResponseEntity . status ( HttpStatus . NOT_FOUND ) . body ( Collections . singletonMap ( "error" , e . getMessage ( ) ) ) ;
} catch ( IOException e ) {
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( Collections . singletonMap ( "error" , "Failed to update image" ) ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( Collections . singletonMap ( "error" , "Failed to update image" ) ) ;
}
}
@ -1239,7 +1171,6 @@ public class AdminAPIController {
return ResponseEntity . ok ( response ) ;
}
@GetMapping ( "/viewsettlement-complete" )
public ResponseEntity < Map < String , Object > > viewSettlementcompleteMaster ( HttpSession session ) {
@ -1342,10 +1273,16 @@ public class AdminAPIController {
List < Users > userList = handleUserRequest ( request , fromDate , toDate , userstatus , usertype ) ;
List < Object [ ] > bookingList = handleBookingRequest ( request , fromDate , toDate , bookingStatus , bookingId ) ;
List < BookingDetails > bookingSettlementList = handleBookingSettlementRequest ( request , fromDate , toDate , refundStatus ) ;
List < Object [ ] > paymentList = request . equals ( "3" ) ? bookingService . getAllPaymentsDetails ( fromDate , toDate ) : new ArrayList < > ( ) ;
List < Object [ ] > userbookingList = request . equals ( "4" ) ? bookingService . getBookingUserDetailsReport ( fromDate , toDate ) : new ArrayList < > ( ) ;
List < Object [ ] > hallbookingList = request . equals ( "5" ) ? bookingService . getBookingHallDetailsReport ( fromDate , toDate ) : new ArrayList < > ( ) ;
List < BookingDetails > bookingSettlementList = handleBookingSettlementRequest ( request , fromDate , toDate ,
refundStatus ) ;
List < Object [ ] > paymentList = request . equals ( "3" ) ? bookingService . getAllPaymentsDetails ( fromDate , toDate )
: new ArrayList < > ( ) ;
List < Object [ ] > userbookingList = request . equals ( "4" )
? bookingService . getBookingUserDetailsReport ( fromDate , toDate )
: new ArrayList < > ( ) ;
List < Object [ ] > hallbookingList = request . equals ( "5" )
? bookingService . getBookingHallDetailsReport ( fromDate , toDate )
: new ArrayList < > ( ) ;
response . put ( "users" , userList ) ;
response . put ( "bookings" , bookingList ) ;
@ -1365,7 +1302,8 @@ public class AdminAPIController {
return new ResponseEntity < > ( response , HttpStatus . OK ) ;
}
private List < Users > handleUserRequest ( String request , String fromDate , String toDate , String userstatus , String usertype ) {
private List < Users > handleUserRequest ( String request , String fromDate , String toDate , String userstatus ,
String usertype ) {
if ( ! request . equals ( "1" ) ) {
return new ArrayList < > ( ) ;
}
@ -1381,7 +1319,8 @@ public class AdminAPIController {
return userService . getAllUsers ( fromDate , toDate ) ;
}
private List < Object [ ] > handleBookingRequest ( String request , String fromDate , String toDate , String bookingStatus , Long bookingId ) {
private List < Object [ ] > handleBookingRequest ( String request , String fromDate , String toDate , String bookingStatus ,
Long bookingId ) {
if ( ! request . equals ( "2" ) ) {
return new ArrayList < > ( ) ;
}
@ -1394,7 +1333,8 @@ public class AdminAPIController {
}
}
private List < BookingDetails > handleBookingSettlementRequest ( String request , String fromDate , String toDate , String refundStatus ) {
private List < BookingDetails > handleBookingSettlementRequest ( String request , String fromDate , String toDate ,
String refundStatus ) {
if ( ! request . equals ( "6" ) ) {
return new ArrayList < > ( ) ;
}
@ -1410,7 +1350,6 @@ public class AdminAPIController {
return ResponseEntity . ok ( halldetails ) ;
}
@GetMapping ( "/listgccblocking" )
public ResponseEntity < Map < String , Object > > getGccBlocking ( ) {
@ -1504,7 +1443,8 @@ public class AdminAPIController {
return ResponseEntity . ok ( "File uploaded and saved successfully" ) ;
} catch ( Exception e ) {
System . err . println ( "Error during file upload: " + e . getMessage ( ) ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( "File upload failed: " + e . getMessage ( ) ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( "File upload failed: " + e . getMessage ( ) ) ;
}
}
}