added filter on title and description on post

This commit is contained in:
SlimusMinus
2026-07-06 00:47:07 +03:00
parent 04f29001ac
commit 97f28b9eca
6 changed files with 84 additions and 69 deletions

View File

@@ -6,10 +6,14 @@ import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
public interface MessageRepository extends JpaRepository<Message, Long> {
List<Message> findByChatIdOrderByCreatedAtAsc(Long chatId);
long countByChatIdAndIsReadFalseAndSenderIdNot(Long chatId, Long currentUserId);
@Modifying
@Query("UPDATE Message m SET m.isRead = true WHERE m.chatId = :chatId AND m.senderId != :userId")
int markAsReadByChatIdAndRecipient(@Param("chatId") Long chatId, @Param("userId") Long userId);
}