From 691c0e5b725c85e2d7cb5afa7dd01fb864c92e49 Mon Sep 17 00:00:00 2001 From: SongJaeHoonn Date: Tue, 14 Jan 2025 17:23:28 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat(Recruitment):=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EB=AA=A8=EC=A7=91=EC=A4=91=EC=9D=B8=20=EB=AA=A8=EC=A7=91?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OpenRecruitmentsRetrievalController.java | 28 +++++++++++++++++++ .../RecruitmentPersistenceAdapter.java | 8 ++++++ .../persistence/RecruitmentRepository.java | 3 ++ .../dto/mapper/RecruitmentDtoMapper.java | 8 ++++++ .../response/RecruitmentOpenResponseDto.java | 13 +++++++++ .../in/RetrieveOpenRecruitmentsUseCase.java | 8 ++++++ .../port/out/RetrieveRecruitmentPort.java | 3 ++ .../OpenRecruitmentsRetrievalService.java | 27 ++++++++++++++++++ .../api/global/config/SecurityConstants.java | 2 +- 9 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/OpenRecruitmentsRetrievalController.java create mode 100644 src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/response/RecruitmentOpenResponseDto.java create mode 100644 src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveOpenRecruitmentsUseCase.java create mode 100644 src/main/java/page/clab/api/domain/hiring/recruitment/application/service/OpenRecruitmentsRetrievalService.java diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/OpenRecruitmentsRetrievalController.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/OpenRecruitmentsRetrievalController.java new file mode 100644 index 000000000..5d390f8cd --- /dev/null +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/OpenRecruitmentsRetrievalController.java @@ -0,0 +1,28 @@ +package page.clab.api.domain.hiring.recruitment.adapter.in.web; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentOpenResponseDto; +import page.clab.api.domain.hiring.recruitment.application.port.in.RetrieveOpenRecruitmentsUseCase; +import page.clab.api.global.common.dto.ApiResponse; + +@RestController +@RequestMapping("/api/v1/recruitments") +@RequiredArgsConstructor +@Tag(name = "Hiring - Recruitment", description = "모집 공고") +public class OpenRecruitmentsRetrievalController { + + private final RetrieveOpenRecruitmentsUseCase retrieveOpenRecruitmentsUseCase; + + @Operation(summary = "현재 모집 중인 모집 공고 목록", description = "ROLE_ANONYMOUS 이상의 권한이 필요함") + @GetMapping("/open") + public ApiResponse> retrieveRecruitmentsByEndDate() { + List recruitments = retrieveOpenRecruitmentsUseCase.retrieveOpenRecruitments(); + return ApiResponse.success(recruitments); + } +} diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentPersistenceAdapter.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentPersistenceAdapter.java index 913b980ca..4990e9b86 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentPersistenceAdapter.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentPersistenceAdapter.java @@ -8,6 +8,7 @@ import page.clab.api.domain.hiring.recruitment.application.port.out.RetrieveRecruitmentPort; import page.clab.api.domain.hiring.recruitment.application.port.out.UpdateRecruitmentPort; import page.clab.api.domain.hiring.recruitment.domain.Recruitment; +import page.clab.api.domain.hiring.recruitment.domain.RecruitmentStatus; import page.clab.api.global.exception.NotFoundException; @Component @@ -62,4 +63,11 @@ public List findByEndDateBetween(LocalDateTime weekAgo, LocalDateTi .map(mapper::toDomain) .toList(); } + + @Override + public List findByStatus(RecruitmentStatus status) { + return repository.findByStatus(status).stream() + .map(mapper::toDomain) + .toList(); + } } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentRepository.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentRepository.java index 171e9fb9d..68b55b9d2 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentRepository.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/out/persistence/RecruitmentRepository.java @@ -4,6 +4,7 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import page.clab.api.domain.hiring.recruitment.domain.RecruitmentStatus; @Repository public interface RecruitmentRepository extends JpaRepository { @@ -11,4 +12,6 @@ public interface RecruitmentRepository extends JpaRepository findTop5ByOrderByCreatedAtDesc(); List findByEndDateBetween(LocalDateTime weekAgo, LocalDateTime now); + + List findByStatus(RecruitmentStatus status); } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/mapper/RecruitmentDtoMapper.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/mapper/RecruitmentDtoMapper.java index 4ec95ff6c..c0d9ce13a 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/mapper/RecruitmentDtoMapper.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/mapper/RecruitmentDtoMapper.java @@ -2,6 +2,7 @@ import org.springframework.stereotype.Component; import page.clab.api.domain.hiring.recruitment.application.dto.request.RecruitmentRequestDto; +import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentOpenResponseDto; import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentDetailsResponseDto; import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentEndDateResponseDto; import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentResponseDto; @@ -59,4 +60,11 @@ public RecruitmentDetailsResponseDto toDetailsDto(Recruitment recruitment) { .updatedAt(recruitment.getUpdatedAt()) .build(); } + + public RecruitmentOpenResponseDto toOpenDto(Recruitment recruitment) { + return RecruitmentOpenResponseDto.builder() + .id(recruitment.getId()) + .applicationType(recruitment.getApplicationType()) + .build(); + } } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/response/RecruitmentOpenResponseDto.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/response/RecruitmentOpenResponseDto.java new file mode 100644 index 000000000..6edb9c787 --- /dev/null +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/dto/response/RecruitmentOpenResponseDto.java @@ -0,0 +1,13 @@ +package page.clab.api.domain.hiring.recruitment.application.dto.response; + +import lombok.Builder; +import lombok.Getter; +import page.clab.api.domain.hiring.application.domain.ApplicationType; + +@Getter +@Builder +public class RecruitmentOpenResponseDto { + + private Long id; + private ApplicationType applicationType; +} diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveOpenRecruitmentsUseCase.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveOpenRecruitmentsUseCase.java new file mode 100644 index 000000000..c5acd54a4 --- /dev/null +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/in/RetrieveOpenRecruitmentsUseCase.java @@ -0,0 +1,8 @@ +package page.clab.api.domain.hiring.recruitment.application.port.in; + +import java.util.List; +import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentOpenResponseDto; + +public interface RetrieveOpenRecruitmentsUseCase { + List retrieveOpenRecruitments(); +} diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RetrieveRecruitmentPort.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RetrieveRecruitmentPort.java index ab19aa86f..1cfdc58f3 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RetrieveRecruitmentPort.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/port/out/RetrieveRecruitmentPort.java @@ -3,6 +3,7 @@ import java.time.LocalDateTime; import java.util.List; import page.clab.api.domain.hiring.recruitment.domain.Recruitment; +import page.clab.api.domain.hiring.recruitment.domain.RecruitmentStatus; public interface RetrieveRecruitmentPort { @@ -13,4 +14,6 @@ public interface RetrieveRecruitmentPort { List findTop5ByOrderByCreatedAtDesc(); List findByEndDateBetween(LocalDateTime weekAgo, LocalDateTime now); + + List findByStatus(RecruitmentStatus status); } diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/OpenRecruitmentsRetrievalService.java b/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/OpenRecruitmentsRetrievalService.java new file mode 100644 index 000000000..92281b57f --- /dev/null +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/application/service/OpenRecruitmentsRetrievalService.java @@ -0,0 +1,27 @@ +package page.clab.api.domain.hiring.recruitment.application.service; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import page.clab.api.domain.hiring.recruitment.application.dto.mapper.RecruitmentDtoMapper; +import page.clab.api.domain.hiring.recruitment.application.dto.response.RecruitmentOpenResponseDto; +import page.clab.api.domain.hiring.recruitment.application.port.in.RetrieveOpenRecruitmentsUseCase; +import page.clab.api.domain.hiring.recruitment.application.port.out.RetrieveRecruitmentPort; +import page.clab.api.domain.hiring.recruitment.domain.RecruitmentStatus; + +@Service +@RequiredArgsConstructor +public class OpenRecruitmentsRetrievalService implements RetrieveOpenRecruitmentsUseCase { + + private final RetrieveRecruitmentPort retrieveRecruitmentPort; + private final RecruitmentDtoMapper mapper; + + @Transactional(readOnly = true) + @Override + public List retrieveOpenRecruitments() { + return retrieveRecruitmentPort.findByStatus(RecruitmentStatus.OPEN).stream() + .map(mapper::toOpenDto) + .toList(); + } +} diff --git a/src/main/java/page/clab/api/global/config/SecurityConstants.java b/src/main/java/page/clab/api/global/config/SecurityConstants.java index 31737819f..6bcf97be0 100644 --- a/src/main/java/page/clab/api/global/config/SecurityConstants.java +++ b/src/main/java/page/clab/api/global/config/SecurityConstants.java @@ -18,7 +18,7 @@ public class SecurityConstants { public static final String[] PERMIT_ALL_API_ENDPOINTS_GET = { "/api/v1/applications/{recruitmentId}/{studentId}", "/api/v1/recruitments", "/api/v1/recruitments/recent-week", - "/api/v1/recruitments/{recruitmentId}", + "/api/v1/recruitments/{recruitmentId}", "/api/v1/recruitments/open", "/api/v1/news", "/api/v1/news/**", "/api/v1/blogs", "/api/v1/blogs/**", "/api/v1/positions", "/api/v1/positions/**", From bc95190aa9661c2b2a219b077bc795ca71aa2c8d Mon Sep 17 00:00:00 2001 From: SongJaeHoonn Date: Tue, 14 Jan 2025 17:30:10 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor(OpenRecruitmentsRetrievalControlle?= =?UTF-8?q?r):=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/in/web/OpenRecruitmentsRetrievalController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/OpenRecruitmentsRetrievalController.java b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/OpenRecruitmentsRetrievalController.java index 5d390f8cd..d51648b1a 100644 --- a/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/OpenRecruitmentsRetrievalController.java +++ b/src/main/java/page/clab/api/domain/hiring/recruitment/adapter/in/web/OpenRecruitmentsRetrievalController.java @@ -21,7 +21,7 @@ public class OpenRecruitmentsRetrievalController { @Operation(summary = "현재 모집 중인 모집 공고 목록", description = "ROLE_ANONYMOUS 이상의 권한이 필요함") @GetMapping("/open") - public ApiResponse> retrieveRecruitmentsByEndDate() { + public ApiResponse> retrieveOpenRecruitments() { List recruitments = retrieveOpenRecruitmentsUseCase.retrieveOpenRecruitments(); return ApiResponse.success(recruitments); }