panel uzytkownika

This commit is contained in:
2026-08-24 14:14:54 +02:00
parent 6c35589e70
commit 1a067cce8c
6 changed files with 476 additions and 263 deletions
@@ -63,6 +63,13 @@ public class NotificationController {
return ResponseEntity.noContent().build();
}
// Wyczyszczenie calego centrum powiadomien ("Usun wszystkie"). Zakres bierzemy z tokenu.
@DeleteMapping("/all")
public ResponseEntity<Void> deleteAll(Authentication authentication) {
notificationService.deleteAll(authentication.getName());
return ResponseEntity.noContent().build();
}
// Zdarzenia liczone po stronie klienta (alerty cenowe, spotkania, ulubione, weryfikacja telefonu,
// dopasowane oferty). Powiadomienie zawsze trafia do zalogowanego uzytkownika (serwer ustawia odbiorce).
@PostMapping
@@ -24,4 +24,9 @@ public interface NotificationRepository extends JpaRepository<Notification, Long
@Query("delete from Notification n where lower(n.userEmail) = lower(:email) "
+ "and n.dedupeKey is not null and n.dedupeKey like :pattern escape '\\'")
int deleteByDedupeKeyPattern(@Param("email") String email, @Param("pattern") String pattern);
// Wyczyszczenie calego centrum powiadomien uzytkownika ("Usun wszystkie").
@Modifying
@Query("delete from Notification n where lower(n.userEmail) = lower(:email)")
int deleteAllForUser(@Param("email") String email);
}
@@ -99,6 +99,15 @@ public class NotificationService {
repository.markAllRead(email);
}
/** Usuwa wszystkie powiadomienia uzytkownika ("Usun wszystkie" w centrum powiadomien). */
@Transactional
public int deleteAll(String email) {
if (email == null || email.isBlank()) {
return 0;
}
return repository.deleteAllForUser(email);
}
// --- SSE ---
public SseEmitter subscribe(String email) {