From e800da48b9e226a70465d8ab22a7ed28367e2f84 Mon Sep 17 00:00:00 2001 From: Vladik-gif Date: Fri, 27 Sep 2024 14:08:42 +0300 Subject: [PATCH] updated: TopicRepository.findByIdAndScopeNotDeleted method and TopicService.getTopic --- .../java/com/chat/yourway/repository/jpa/TopicRepository.java | 2 +- src/main/java/com/chat/yourway/service/TopicService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chat/yourway/repository/jpa/TopicRepository.java b/src/main/java/com/chat/yourway/repository/jpa/TopicRepository.java index 14660c8..b6d7f9d 100644 --- a/src/main/java/com/chat/yourway/repository/jpa/TopicRepository.java +++ b/src/main/java/com/chat/yourway/repository/jpa/TopicRepository.java @@ -34,7 +34,7 @@ public interface TopicRepository extends JpaRepository { Optional findByName(@Param("name") String name); @Query(value = "SELECT t FROM Topic t Where t.id = :id and t.scope != 'DELETED'") - Optional findById(@Param("id") UUID id); + Optional findByIdAndScopeNotDeleted(@Param("id") UUID id); @Query(value = """ SELECT t FROM Topic t JOIN FETCH t.topicSubscribers s diff --git a/src/main/java/com/chat/yourway/service/TopicService.java b/src/main/java/com/chat/yourway/service/TopicService.java index 80d0e04..34db519 100644 --- a/src/main/java/com/chat/yourway/service/TopicService.java +++ b/src/main/java/com/chat/yourway/service/TopicService.java @@ -202,7 +202,7 @@ public Topic save(Topic topic) { public Topic getTopic(UUID topicId) { return topicRepository - .findById(topicId) + .findByIdAndScopeNotDeleted(topicId) .orElseThrow( () -> { log.warn("Topic id: {} wasn't found", topicId);