package com.izouma.wenlvju.service;

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

@Service
@AllArgsConstructor
public class AnnouncementService {

    private AnnouncementRepo announcementRepo;

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