package com.izouma.wenlvju.service;

import com.izouma.wenlvju.domain.Person;
import com.izouma.wenlvju.dto.PageQuery;
import com.izouma.wenlvju.repo.PersonRepo;
import com.izouma.wenlvju.utils.JpaUtils;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class PersonService {

    private PersonRepo personRepo;

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