package com.izouma.nineth.service;

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

@Service
@AllArgsConstructor
public class NewsService {

    private NewsRepo newsRepo;

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