Added Read/Unread filter in notification API.

This commit is contained in:
piyushkag
2024-12-30 15:25:32 +05:30
parent 172c2bec62
commit 8fba9a1c81
5 changed files with 26 additions and 18 deletions

View File

@@ -33,8 +33,8 @@ public interface NotificationApi {
ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) })
@PostMapping(value = "/user/{userId}/sent", consumes = "application/json", produces = "application/json")
ResponseEntity<Response<NotificationResponse>> sendNotification(HttpServletRequest request, @RequestBody NotificationReq notificationReq,
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId,
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId);
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId);
@Operation(summary = "Api to get notification by id", responses = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@@ -93,7 +93,8 @@ public interface NotificationApi {
@GetMapping(value = "/user/{userId}/company/{companyId}/notifications", produces = "application/json")
ResponseEntity<Response<List<NotificationResponse>>> getNotificationsByUserIdAndCompanyId(HttpServletRequest request,
@Parameter(description = "The user id", required = true) @PathVariable(value = "userId") Long userId,
@Parameter(description = "The company ID", required = true) @PathVariable(value = "companyId") Long companyId);
@Parameter(description = "The company ID", required = true) @PathVariable(value = "companyId") Long companyId,
@Parameter(description = "The notification status", required = false) @RequestParam(value = "status", required = false) List<NotificationEnum> statuses);
}

View File

@@ -65,8 +65,8 @@ public class NotificationApiController implements NotificationApi {
}
@Override
public ResponseEntity<Response<List<NotificationResponse>>> getNotificationsByUserIdAndCompanyId(HttpServletRequest request,Long userId, Long companyId) {
List<NotificationResponse> notificationResponses = notificationService.getNotificationsByCompanyIdAndUserId(userId, companyId);
public ResponseEntity<Response<List<NotificationResponse>>> getNotificationsByUserIdAndCompanyId(HttpServletRequest request,Long userId, Long companyId, List<NotificationEnum> statuses) {
List<NotificationResponse> notificationResponses = notificationService.getNotificationsByCompanyIdAndUserId(userId, companyId, statuses);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(notificationResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.NOTIFICATION_FETCHED_SUCCESSFULLY)));
}