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);