diff --git a/.classpath b/.classpath
index c6d54598..d91be04b 100644
--- a/.classpath
+++ b/.classpath
@@ -29,15 +29,6 @@
-
-
-
-
-
-
-
-
-
@@ -48,6 +39,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index b83d2226..c2187eec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,7 @@
/target/
+target/classes/
+.classpath
+/communityHallDocuments/
+target/classes/application-dev.properties
+target/classes/application-prod.properties
+
diff --git a/jwtToken.txt b/jwtToken.txt
index 4f50d0f6..7324af95 100644
--- a/jwtToken.txt
+++ b/jwtToken.txt
@@ -1 +1 @@
-eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVHlwZSI6ImFkbWluIiwiaGFsbElkIjoxLCJtb2JpbGVOdW1iZXIiOjgzNDQ5NzkyOTIsImVtcGxveWVlSWQiOiIxIiwiem9uZSI6IjAwIiwiZXhwIjoxNzYyODYwNzk0fQ.ltHuRFZWZqHUvUki5jbMcGTDbU2JyOWU5cgMFbVrp_8KMag9HVtHQ9iSFGUyIMUe_T08b58_BG9ZtrtM8rHo9Q
\ No newline at end of file
+eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVHlwZSI6ImFkbWluIiwiaGFsbElkIjoxLCJtb2JpbGVOdW1iZXIiOjgzNDQ5NzkyOTIsImVtcGxveWVlSWQiOiIxIiwiem9uZSI6IjAwIiwiZXhwIjoxNzczMTIyNTkxfQ.6cTw68Q9NsMgdKLtP7D1k0I_6PJQ62mFIOItwtpYz7o7FNC_Kf0qRzulFguzgnPpdvSwXF2v2w_PqIXte7eIMg
\ No newline at end of file
diff --git a/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java b/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
index 28f68d7c..02c703a8 100644
--- a/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
+++ b/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
@@ -71,6 +71,7 @@ import com.gcc.communityHall.repository.DiscountRangeRepository;
import com.gcc.communityHall.repository.GccBlockingDateRepository;
import com.gcc.communityHall.repository.GccBlockingHistoryRepository;
import com.gcc.communityHall.repository.HallDetailsRepository;
+import com.gcc.communityHall.repository.HallReasonRestrictionRepository;
import com.gcc.communityHall.repository.HallImagesRepository;
import com.gcc.communityHall.repository.NotificationRepository;
import com.gcc.communityHall.repository.ReasonMasterRepository;
@@ -97,10 +98,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("/communityhall/admin/api")
@AllArgsConstructor
@@ -168,32 +166,13 @@ public class AdminAPIController {
@Autowired
private ApplicationLogsRepository applicationLogsRepository;
- @Operation(
- summary = "Update HallDetails REST API",
- description = "REST API to update the Hall Details"
- )
+ @Autowired
+ private HallReasonRestrictionRepository hallReasonRestrictionRepository;
+
+ @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 updateHallInfo(
@@ -270,43 +249,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 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 +284,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 getHallDetails(@PathVariable String hallId) {
@@ -362,7 +300,7 @@ public class AdminAPIController {
}
HallDetails hallDetails = hallDetailsRepository.findHallDetailsById(id);
- //System.out.println(hallDetails.isActive());
+ // System.out.println(hallDetails.isActive());
if (hallDetails != null) {
return ResponseEntity.ok(hallDetails);
} else {
@@ -370,10 +308,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 +362,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 existingDiscount = discountRangeRepo.findById(id);
if (existingDiscount.isPresent()) {
@@ -462,11 +395,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 deleteDiscountRangeById(@PathVariable int id) {
if (discountRangeRepo.existsById(id)) {
@@ -523,70 +452,77 @@ public class AdminAPIController {
}
- @Operation(
- summary = "Retrieving the Discount Details REST API",
- description = "REST API to Retrieve the Discount Details for usertypes"
- )
- //Retrieving the Discount Details
+ @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 getDIscountDetails(@RequestParam("id") int id) {
Optional discountdetails = discountRangeRepo.findById(id);
return discountdetails;
}
- @Operation(
- summary = "Save Reasons REST API",
- description = "REST API to save the reasons"
- )
- //saving the Reason
+ @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"
- )
- //retrieving the allreasons
+ @Operation(summary = "All Reasons REST API", description = "REST API to retrie the allreasons")
+ // retrieving the allreasons
@GetMapping("/getReasons")
@ResponseBody
public List getAllReasons() {
return reasonMasterService.getAllReasons();
}
- @Operation(
- summary = "Reason Documents by reasonId REST API",
- description = "REST API to Get the ReasonDocuments By reasonId"
- )
- //Getting ReasonDocuments By reasonId
+ // retrieving allowed reasons for a specific hall (filtered by restriction)
+ @GetMapping("/getAllowedReasons")
+ @ResponseBody
+ public List getAllowedReasons(@RequestParam int hallId) {
+ HallDetails hallDetails = hallDetailsRepository.findHallDetailsById(hallId);
+ if (hallDetails != null && hallDetails.isReasonRestricted()) {
+ List allowedReasonIds = hallReasonRestrictionRepository.findReasonIdsByHallId(hallId);
+ if (!allowedReasonIds.isEmpty()) {
+ List allReasons = reasonMasterService.getAllReasons();
+ return allReasons.stream()
+ .filter(r -> allowedReasonIds.contains(r.getReasonId()))
+ .collect(java.util.stream.Collectors.toList());
+ }
+ }
+ return reasonMasterService.getAllReasons();
+ }
+
+ @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 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"
- )
-// @GetMapping("/filter")
-// public ResponseEntity> getFilteredBookings(
-// @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
-// @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate,
-// @RequestParam("hallIds") List hallIds) {
-//
-// List bookings = bookingService.getFilteredBookings(fromDate, toDate, hallIds);
-//
-// List responses = new ArrayList<>();
-// for (BookingDetails bookingDetails : bookings) {
-// // Fetch GccBlockingDate records for each bookingId
-// List gccBlockedList = blockingDateRepository.getByBookingId(bookingDetails.getBookingId());
-// Integer blockingId = gccBlockedList.isEmpty() ? null : gccBlockedList.get(0).getBlockingId();
-// responses.add(new BookingResponseDTO(bookingDetails, blockingId));
-// }
-//
-// return ResponseEntity.ok(responses);
-// }
+ @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> getFilteredBookings(
+ // @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
+ // fromDate,
+ // @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate
+ // toDate,
+ // @RequestParam("hallIds") List hallIds) {
+ //
+ // List bookings = bookingService.getFilteredBookings(fromDate,
+ // toDate, hallIds);
+ //
+ // List responses = new ArrayList<>();
+ // for (BookingDetails bookingDetails : bookings) {
+ // // Fetch GccBlockingDate records for each bookingId
+ // List gccBlockedList =
+ // blockingDateRepository.getByBookingId(bookingDetails.getBookingId());
+ // Integer blockingId = gccBlockedList.isEmpty() ? null :
+ // gccBlockedList.get(0).getBlockingId();
+ // responses.add(new BookingResponseDTO(bookingDetails, blockingId));
+ // }
+ //
+ // return ResponseEntity.ok(responses);
+ // }
@GetMapping("/filter")
public ResponseEntity