Fix unread notifications query
This commit is contained in:
parent
186ab6d50c
commit
5009440bf5
@ -17,7 +17,7 @@ package org.thingsboard.server.service.ws.notification;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@ -44,8 +44,9 @@ public interface NotificationRepository extends JpaRepository<NotificationEntity
|
|||||||
@Param("searchText") String searchText,
|
@Param("searchText") String searchText,
|
||||||
Pageable pageable);
|
Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT n FROM NotificationEntity n WHERE n.recipientId = :recipientId " +
|
@Query("SELECT n FROM NotificationEntity n WHERE n.deliveryMethod = :deliveryMethod " +
|
||||||
"AND n.status <> :status AND (n.type IN :types) " +
|
"AND n.recipientId = :recipientId AND n.status <> :status " +
|
||||||
|
"AND (n.type IN :types) " +
|
||||||
"AND (:searchText is NULL OR ilike(n.subject, concat('%', :searchText, '%')) = true " +
|
"AND (:searchText is NULL OR ilike(n.subject, concat('%', :searchText, '%')) = true " +
|
||||||
"OR ilike(n.text, concat('%', :searchText, '%')) = true)")
|
"OR ilike(n.text, concat('%', :searchText, '%')) = true)")
|
||||||
Page<NotificationEntity> findByDeliveryMethodAndRecipientIdAndTypeInAndStatusNot(@Param("deliveryMethod") NotificationDeliveryMethod deliveryMethod,
|
Page<NotificationEntity> findByDeliveryMethodAndRecipientIdAndTypeInAndStatusNot(@Param("deliveryMethod") NotificationDeliveryMethod deliveryMethod,
|
||||||
@ -55,7 +56,8 @@ public interface NotificationRepository extends JpaRepository<NotificationEntity
|
|||||||
@Param("searchText") String searchText,
|
@Param("searchText") String searchText,
|
||||||
Pageable pageable);
|
Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT n FROM NotificationEntity n WHERE n.deliveryMethod = :deliveryMethod AND n.recipientId = :recipientId " +
|
@Query("SELECT n FROM NotificationEntity n WHERE n.deliveryMethod = :deliveryMethod " +
|
||||||
|
"AND n.recipientId = :recipientId " +
|
||||||
"AND (:searchText is NULL OR ilike(n.subject, concat('%', :searchText, '%')) = true " +
|
"AND (:searchText is NULL OR ilike(n.subject, concat('%', :searchText, '%')) = true " +
|
||||||
"OR ilike(n.text, concat('%', :searchText, '%')) = true)")
|
"OR ilike(n.text, concat('%', :searchText, '%')) = true)")
|
||||||
Page<NotificationEntity> findByDeliveryMethodAndRecipientId(@Param("deliveryMethod") NotificationDeliveryMethod deliveryMethod,
|
Page<NotificationEntity> findByDeliveryMethodAndRecipientId(@Param("deliveryMethod") NotificationDeliveryMethod deliveryMethod,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user