Skip to content
Snippets Groups Projects
Commit f8aed936 authored by evilimkova's avatar evilimkova Committed by Martin Gargalovič
Browse files

FindAll - Pageable

parent 3bd7cdee
No related branches found
No related tags found
3 merge requests!31M2,!28M2 user,!27Draft: M2 user
...@@ -6,6 +6,8 @@ import org.fuseri.model.dto.certificate.CertificateDto; ...@@ -6,6 +6,8 @@ import org.fuseri.model.dto.certificate.CertificateDto;
import org.fuseri.model.dto.certificate.CertificateSimpleDto; import org.fuseri.model.dto.certificate.CertificateSimpleDto;
import org.fuseri.model.dto.common.Result; import org.fuseri.model.dto.common.Result;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -91,7 +93,7 @@ public class CertificateController { ...@@ -91,7 +93,7 @@ public class CertificateController {
* @return a Result object containing a list of CertificateDto objects and pagination information * @return a Result object containing a list of CertificateDto objects and pagination information
*/ */
@GetMapping("/findAll") @GetMapping("/findAll")
public Result<CertificateDto> findAllCertificates(@RequestParam int page) { public Page<CertificateSimpleDto> findAllCertificates(Pageable pageable) {
return new Result<>(); return certificateFacade.findAll(pageable);
} }
} }
...@@ -49,10 +49,10 @@ public class CertificateFacade { ...@@ -49,10 +49,10 @@ public class CertificateFacade {
return certificateMapper.mapToList(certificateService.findByUserIdAndCourseId(userId, courseId)); return certificateMapper.mapToList(certificateService.findByUserIdAndCourseId(userId, courseId));
} }
//@Transactional(readOnly = true) @Transactional(readOnly = true)
//public Page<CertificateDto> findAll(Pageable pageable) { public Page<CertificateSimpleDto> findAll(Pageable pageable) {
//return certificateMapper.mapToPageDto(certificateService.findAll(pageable)); return certificateMapper.mapToPageDto(certificateService.findAll(pageable));
//} }
@Transactional @Transactional
public void deleteCertificate(Long certificateId) { public void deleteCertificate(Long certificateId) {
......
...@@ -44,7 +44,7 @@ public interface CertificateMapper { ...@@ -44,7 +44,7 @@ public interface CertificateMapper {
List<CertificateSimpleDto> mapToList(List<Certificate> certificates); List<CertificateSimpleDto> mapToList(List<Certificate> certificates);
//default Page<CertificateDto> mapToPageDto(Page<Certificate> certificates) { default Page<CertificateSimpleDto> mapToPageDto(Page<Certificate> certificates) {
//return new PageImpl<>(mapToList(certificates.getContent()), certificates.getPageable(), certificates.getTotalPages()); return new PageImpl<>(mapToList(certificates.getContent()), certificates.getPageable(), certificates.getTotalPages());
//} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment