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
|
@Transactional
|
||||||
public void deleteNotificationPreferences(String userId) {
|
public void deleteNotificationPreferences(String userId) {
|
||||||
|
|
||||||
notificationPreferencesRepository.deleteById(userId);
|
notificationPreferencesRepository.deleteByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public NotificationPreferencesEntity getOrCreateNotificationPreferences(String userId) {
|
public NotificationPreferencesEntity getOrCreateNotificationPreferences(String userId) {
|
||||||
|
|
||||||
return notificationPreferencesRepository.findById(userId).orElseGet(() -> {
|
return notificationPreferencesRepository.findByUserId(userId).orElseGet(() -> {
|
||||||
|
|
||||||
var notificationPreference = new NotificationPreferencesEntity();
|
var notificationPreference = new NotificationPreferencesEntity();
|
||||||
notificationPreference.setUserId(userId);
|
notificationPreference.setUserId(userId);
|
||||||
@ -82,9 +82,7 @@ public class NotificationPreferencesPersistenceService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void initializePreferencesIfNotExists(String userId) {
|
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;
|
package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.entity.notification.NotificationPreferencesEntity;
|
import com.iqser.red.service.persistence.management.v1.processor.entity.notification.NotificationPreferencesEntity;
|
||||||
|
|
||||||
public interface NotificationPreferencesRepository extends JpaRepository<NotificationPreferencesEntity, String> {
|
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