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;
}
}
-19
View File
@@ -1,19 +0,0 @@
notification.search.result=Результат поиска готов
notification.monitoring.result=Результат мониторинга доступен
notification.operation.impossible=Операция невозможна
notification.start.failed.now=Запуск не удался
notification.start.failed.next=Запуск не удался
notification.payout.result=Результат выплаты {0}
notification.payment.result=Результат оплаты {0}
notification.referral.deposit=Реферальный депозит
notification.referral.registered=Новый реферал зарегистрирован
notification.referral.activated=Реферал активирован
notification.complaint.status=Статус жалобы изменён: {0}
notification.case.status=Статус дела изменён
notification.incoming.message=Новое сообщение
notification.tariff.expiring=Тариф скоро истекает
notification.token.not.found=Недостаточно токенов для операции: {0}
notification.file.moderation=Файл проходит модерацию
notification.file.added=Файл {0} добавлен в систему
notification.file.search=Поиск файла
notification.search.operation.filed=Поиск завершился непредвиденной ошибкой
-15
View File
@@ -1,15 +0,0 @@
notification.search.result=Search result is ready
notification.monitoring.result=Monitoring result is available
notification.operation.impossible=Operation impossible
notification.start.failed.now=Start failed
notification.start.failed.next=Start failed
notification.payout.result=Payout result
notification.referral.deposit=Referral deposit
notification.referral.registered=New referral registered
notification.referral.activated=Referral activated
notification.complaint.status=Complaint status changed
notification.case.status=Case status changed
notification.incoming.message=New message
notification.tariff.expiring=Tariff expiring soon
notification.file.moderation=File is being moderated
notification.file.added=File {0} added to the system