package com.izouma.jiashanxia.service;

import com.izouma.jiashanxia.domain.Article;
import com.izouma.jiashanxia.dto.PageQuery;
import com.izouma.jiashanxia.repo.ArticleRepo;
import com.izouma.jiashanxia.utils.JpaUtils;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class ArticleService {

    private ArticleRepo articleRepo;

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