package com.izouma.jiashanxia.service;

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

@Service
@AllArgsConstructor
public class FeedbackService {

    private FeedbackRepo feedbackRepo;

    public Page<Feedback> all(PageQuery pageQuery) {
        pageQuery.setSort("createdAt,desc");
        return feedbackRepo.findAll(JpaUtils.toSpecification(pageQuery, Feedback.class), JpaUtils.toPageRequest(pageQuery));
    }
}
