package com.izouma.nineth.service;

import com.izouma.nineth.domain.Message;
import com.izouma.nineth.dto.PageQuery;
import com.izouma.nineth.repo.MessageRepo;
import com.izouma.nineth.utils.JpaUtils;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class MessageService {

    private MessageRepo messageRepo;

    public Page<Message> all(PageQuery pageQuery) {
        return messageRepo.findAll(JpaUtils.toSpecification(pageQuery, Message.class), JpaUtils.toPageRequest(pageQuery));
    }
}
