RED-6310: Corrected services so that they use the user id instead of wrongly using the entity id
This commit is contained in:
parent
40d6961742
commit
643ffc8723
@ -60,14 +60,14 @@ public class NotificationPreferencesPersistenceService {
|
||||
@Transactional
|
||||
public void deleteNotificationPreferences(String userId) {
|
||||
|
||||
notificationPreferencesRepository.deleteById(userId);
|
||||
notificationPreferencesRepository.deleteByUserId(userId);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public NotificationPreferencesEntity getOrCreateNotificationPreferences(String userId) {
|
||||
|
||||
return notificationPreferencesRepository.findById(userId).orElseGet(() -> {
|
||||
return notificationPreferencesRepository.findByUserId(userId).orElseGet(() -> {
|
||||
|
||||
var notificationPreference = new NotificationPreferencesEntity();
|
||||
notificationPreference.setUserId(userId);
|
||||
@ -82,9 +82,7 @@ public class NotificationPreferencesPersistenceService {
|
||||
@Transactional
|
||||
public void initializePreferencesIfNotExists(String userId) {
|
||||
|
||||
if (!notificationPreferencesRepository.existsByUserId(userId)) {
|
||||
getOrCreateNotificationPreferences(userId);
|
||||
}
|
||||
getOrCreateNotificationPreferences(userId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.notification.NotificationPreferencesEntity;
|
||||
|
||||
public interface NotificationPreferencesRepository extends JpaRepository<NotificationPreferencesEntity, String> {
|
||||
|
||||
boolean existsByUserId(String userId);
|
||||
Optional<NotificationPreferencesEntity> findByUserId(String userId);
|
||||
|
||||
|
||||
void deleteByUserId(String userId);
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user