diff --git a/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java b/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java index a07b81f..32f759f 100644 --- a/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java +++ b/src/main/java/team18/team18_be/recruitment/controller/RecruitmentController.java @@ -18,6 +18,7 @@ import team18.team18_be.auth.entity.User; import team18.team18_be.config.resolver.LoginUser; import team18.team18_be.recruitment.dto.request.RecruitmentRequest; +import team18.team18_be.recruitment.dto.response.RecruitmentAllResponse; import team18.team18_be.recruitment.dto.response.RecruitmentResponse; import team18.team18_be.recruitment.dto.response.RecruitmentResponseForCompany; import team18.team18_be.recruitment.dto.response.RecruitmentSummationResponse; @@ -46,7 +47,7 @@ public ResponseEntity saveRecruitment( @Operation(summary = "구인글 전체 조회 메서드") @GetMapping - public ResponseEntity> getAllRecruitments( + public ResponseEntity getAllRecruitments( @RequestParam int page ) { int fixedPageSize = 4; @@ -83,7 +84,7 @@ public ResponseEntity setRecruitmentHiringFalse( @Operation(summary = "최근 올라온 구인글 순서대로 정렬") @GetMapping("/latestRegistration") - public ResponseEntity> getAllRecruitmentsLatestRegistration( + public ResponseEntity getAllRecruitmentsLatestRegistration( @RequestParam int page ) { int fixedPageSize = 4; @@ -93,7 +94,7 @@ public ResponseEntity> getAllRecruitmentsLate @Operation(summary = "급여 높은 순서대로 정리해서 전체 구인글 반환하는 메서드") @GetMapping("/salary") - public ResponseEntity> getAllRecruitmentsSalary( + public ResponseEntity getAllRecruitmentsSalary( @RequestParam int page ) { int fixedPageSize = 4; diff --git a/src/main/java/team18/team18_be/recruitment/dto/response/PageDto.java b/src/main/java/team18/team18_be/recruitment/dto/response/PageDto.java new file mode 100644 index 0000000..e127c50 --- /dev/null +++ b/src/main/java/team18/team18_be/recruitment/dto/response/PageDto.java @@ -0,0 +1,7 @@ +package team18.team18_be.recruitment.dto.response; + +public record PageDto( + Integer totalPage +) { + +} diff --git a/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentAllResponse.java b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentAllResponse.java new file mode 100644 index 0000000..90beb63 --- /dev/null +++ b/src/main/java/team18/team18_be/recruitment/dto/response/RecruitmentAllResponse.java @@ -0,0 +1,10 @@ +package team18.team18_be.recruitment.dto.response; + +import java.util.List; + +public record RecruitmentAllResponse( + List content, + PageDto pageable +) { + +} diff --git a/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java b/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java index 7ae0e7e..9ae60ca 100644 --- a/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java +++ b/src/main/java/team18/team18_be/recruitment/service/RecruitmentService.java @@ -10,6 +10,8 @@ import org.springframework.stereotype.Service; import team18.team18_be.config.infrastructure.OpenAiService; import team18.team18_be.recruitment.dto.request.RecruitmentRequest; +import team18.team18_be.recruitment.dto.response.PageDto; +import team18.team18_be.recruitment.dto.response.RecruitmentAllResponse; import team18.team18_be.recruitment.dto.response.RecruitmentResponse; import team18.team18_be.recruitment.dto.response.RecruitmentResponseForCompany; import team18.team18_be.recruitment.dto.response.RecruitmentSummationResponse; @@ -58,9 +60,10 @@ public void saveRecruitment(RecruitmentRequest recruitmentRequest) } - public List getAllRecruitment(Pageable pageable) { + public RecruitmentAllResponse getAllRecruitment(Pageable pageable) { Page recruitments = recruitmentRepository.findAllByHiringTrue(pageable); - return recruitments.stream() + List recruitmentSummationResponseList = + recruitments.stream() .map(recruitment -> new RecruitmentSummationResponse( recruitment.getRecruitmentId(), recruitment.getCompany().getLogoImage(), @@ -71,38 +74,46 @@ public List getAllRecruitment(Pageable pageable) { recruitment.getArea() )) .collect(Collectors.toList()); + int totalPage = recruitments.getTotalPages(); + return new RecruitmentAllResponse(recruitmentSummationResponseList,new PageDto(totalPage)); } - public List getAllRecruitmentAndSortBySalary(Pageable pageable) { + public RecruitmentAllResponse getAllRecruitmentAndSortBySalary(Pageable pageable) { Page recruitments = recruitmentRepository.findAllByHiringTrueOrderBySalaryDesc( pageable); - return recruitments.stream() - .map(recruitment -> new RecruitmentSummationResponse( - recruitment.getRecruitmentId(), - recruitment.getCompany().getLogoImage(), - recruitment.getKoreanTitle(), - recruitment.getVietnameseTitle(), - recruitment.getCompanyName(), - recruitment.getSalary(), - recruitment.getArea() - )) - .collect(Collectors.toList()); + List recruitmentSummationResponseList = + recruitments.stream() + .map(recruitment -> new RecruitmentSummationResponse( + recruitment.getRecruitmentId(), + recruitment.getCompany().getLogoImage(), + recruitment.getKoreanTitle(), + recruitment.getVietnameseTitle(), + recruitment.getCompanyName(), + recruitment.getSalary(), + recruitment.getArea() + )) + .collect(Collectors.toList()); + int totalPage = recruitments.getTotalPages(); + return new RecruitmentAllResponse(recruitmentSummationResponseList,new PageDto(totalPage)); } - public List getAllRecruitmentAndSortByDate(Pageable pageable) { + public RecruitmentAllResponse getAllRecruitmentAndSortByDate(Pageable pageable) { Page recruitments = recruitmentRepository.findAllByHiringTrueOrderByUploadDateDesc( pageable); - return recruitments.stream() - .map(recruitment -> new RecruitmentSummationResponse( - recruitment.getRecruitmentId(), - recruitment.getCompany().getLogoImage(), - recruitment.getKoreanTitle(), - recruitment.getVietnameseTitle(), - recruitment.getCompanyName(), - recruitment.getSalary(), - recruitment.getArea() - )) - .collect(Collectors.toList()); + List recruitmentSummationResponseList = + recruitments.stream() + .map(recruitment -> new RecruitmentSummationResponse( + recruitment.getRecruitmentId(), + recruitment.getCompany().getLogoImage(), + recruitment.getKoreanTitle(), + recruitment.getVietnameseTitle(), + recruitment.getCompanyName(), + recruitment.getSalary(), + recruitment.getArea() + )) + .collect(Collectors.toList()); + int totalPage = recruitments.getTotalPages(); + return new RecruitmentAllResponse(recruitmentSummationResponseList,new PageDto(totalPage)); } public RecruitmentResponse getRecruitmentResponseByRecruitmentId(Long userId) {