fixed controllers
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.krylov.refound.repository;
|
||||
|
||||
import com.krylov.refound.dto.DialogResponse;
|
||||
import com.krylov.refound.entity.Message;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@@ -10,10 +12,14 @@ 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);
|
||||
Page<Message> findByChatIdOrderByCreatedAtDesc(Long chatId, Pageable pageable);
|
||||
|
||||
Optional<Message> findFirstByChatIdOrderByCreatedAtDesc(Long chatId);
|
||||
|
||||
long countByChatIdAndIsReadFalseAndSenderIdNot(Long chatId, Long userId);
|
||||
|
||||
@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);
|
||||
@Query("update Message m set m.isRead = true where m.chatId = :chatId and m.senderId != :userId")
|
||||
void markAsReadByChatIdAndRecipient(@Param("chatId") Long chatId, @Param("userId") Long userId);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user