You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

25 lines
1.3 KiB

package app.repositories;
import app.entities.messages.Message;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
public interface MessageRepository extends PagingAndSortingRepository<Message, Long> {
@Query(value = "select m from Message m where " +
"(:account_ids_non_exists = true or m.account_id in :account_ids) and " +
"(:begin_date is null or m.utime >= :begin_date) and " +
"(:end_date is null or :end_date >= m.utime) and " +
"(:message_contain is null or m.message like :message_contain) and " +
"(:server_id is null or m.server_id like :server_id) order by m.id desc ")
Page<Message> getMessages(Pageable pageable,
@Param(value = "account_ids_non_exists") Boolean account_ids_non_exists,
@Param(value = "account_ids") Iterable<Long> account_ids,
@Param(value = "begin_date") Long begin_date,
@Param(value = "end_date") Long end_date,
@Param(value = "message_contain") String message_contain,
@Param(value = "server_id") String message_id);
}