dev add delete method
Test Workflow / test (push) Successful in 11s

This commit is contained in:
vladp
2026-04-07 10:08:53 +07:00
parent 077902f4ab
commit d8f6a08a2f
6 changed files with 53 additions and 54 deletions
@@ -4,7 +4,7 @@ import lombok.Getter;
@Getter
public enum NotificationMessage {
FILE_SEARCH("notification.file.search");
FILE_SEARCH("notification-file-search");
private final String messageKey;
@@ -4,24 +4,24 @@ import lombok.Getter;
@Getter
public enum NotificationType {
SEARCH_RESULT("notification.search.result"),
MONITORING_RESULT("notification.monitoring.result"),
OPERATION_IMPOSSIBLE("notification.operation.impossible"),
START_FAILED_NOW("notification.start.failed.now"),
START_FAILED_NEXT("notification.start.failed.next"),
PAYOUT_RESULT("notification.payout.result"),
PAYMENT_RESULT("notification.payment.result"),
REFERRAL_DEPOSIT("notification.referral.deposit"),
REFERRAL_REGISTERED("notification.referral.registered"),
REFERRAL_ACTIVATED("notification.referral.activated"),
COMPLAINT_STATUS_CHANGED("notification.complaint.status"),
CASE_STATUS_CHANGED("notification.case.status"),
INCOMING_MESSAGE("notification.incoming.message"),
TARIFF_EXPIRING("notification.tariff.expiring"),
TOKEN_NOT_FOUND("notification.token.not.found"),
FILE_MODERATION_EVENT("notification.file.moderation"),
FILE_ADDED_TO_SYSTEM("notification.file.added"),
SEARCH_OPERATION_FAILED("notification.search.operation.filed");
SEARCH_RESULT("notification-search-result"),
MONITORING_RESULT("notification-monitoring-result"),
OPERATION_IMPOSSIBLE("notification-operation-impossible"),
START_FAILED_NOW("notification-start-failed-now"),
START_FAILED_NEXT("notification-start-failed-next"),
PAYOUT_RESULT("notification-payout-result"),
PAYMENT_RESULT("notification-payment-result"),
REFERRAL_DEPOSIT("notification-referral-deposit"),
REFERRAL_REGISTERED("notification-referral-registered"),
REFERRAL_ACTIVATED("notification-referral-activated"),
COMPLAINT_STATUS_CHANGED("notification-complaint-status"),
CASE_STATUS_CHANGED("notification-case-status"),
INCOMING_MESSAGE("notification-incoming-message"),
TARIFF_EXPIRING("notification-tariff-expiring"),
TOKEN_NOT_FOUND("notification-token-not-found"),
FILE_MODERATION_EVENT("notification-file-moderation"),
FILE_ADDED_TO_SYSTEM("notification-file-added"),
SEARCH_OPERATION_FAILED("notification-search-operation-filed");
private final String messageKey;
@@ -122,10 +122,27 @@ public class NotificationHandler implements RequestHandler {
response);
}
case "delete": {
MarkAsReadRequest markRequest = objectMapper.convertValue(request.getMessageBody(),
MarkAsReadRequest.class);
int delete = notificationService.delete(markRequest.getNotificationIds());
MarkAsReadResponse response = MarkAsReadResponse.builder()
.success(true)
.updatedCount(delete)
.build();
return new BaseResponse(request.getMsgId(),
MessageCode.SUCCESS.getCode(),
MessageCode.SUCCESS.getDescription(),
response);
}
default:
ActionResponse response = ActionResponse.builder()
.action(action)
.availableActions(Arrays.asList("list", "active", "markRead"))
.availableActions(Arrays.asList("list", "active", "markRead", "delete"))
.build();
return new BaseResponse(request.getMsgId(),
@@ -116,4 +116,20 @@ public class NotificationService {
return notificationRepository.updateStatus(notificationIds, user, NotificationStatus.NEW,
NotificationStatus.READIED, LocalDateTime.now());
}
@Transactional
public int delete(List<Long> notificationIds) {
if (notificationIds == null || notificationIds.isEmpty()) {
return 0;
}
int count = 0;
for (Long notificationId : notificationIds) {
notificationRepository.deleteById(notificationId);
count += 1;
}
return count;
}
}