Skip to content

Commit

Permalink
feat(Recruitment): 현재 모집중인 모집공고 목록 조회 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
SongJaeHoonn committed Jan 14, 2025
1 parent 29deb03 commit 691c0e5
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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<List<RecruitmentOpenResponseDto>> retrieveRecruitmentsByEndDate() {
List<RecruitmentOpenResponseDto> recruitments = retrieveOpenRecruitmentsUseCase.retrieveOpenRecruitments();
return ApiResponse.success(recruitments);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -62,4 +63,11 @@ public List<Recruitment> findByEndDateBetween(LocalDateTime weekAgo, LocalDateTi
.map(mapper::toDomain)
.toList();
}

@Override
public List<Recruitment> findByStatus(RecruitmentStatus status) {
return repository.findByStatus(status).stream()
.map(mapper::toDomain)
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
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<RecruitmentJpaEntity, Long> {

List<RecruitmentJpaEntity> findTop5ByOrderByCreatedAtDesc();

List<RecruitmentJpaEntity> findByEndDateBetween(LocalDateTime weekAgo, LocalDateTime now);

List<RecruitmentJpaEntity> findByStatus(RecruitmentStatus status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<RecruitmentOpenResponseDto> retrieveOpenRecruitments();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -13,4 +14,6 @@ public interface RetrieveRecruitmentPort {
List<Recruitment> findTop5ByOrderByCreatedAtDesc();

List<Recruitment> findByEndDateBetween(LocalDateTime weekAgo, LocalDateTime now);

List<Recruitment> findByStatus(RecruitmentStatus status);
}
Original file line number Diff line number Diff line change
@@ -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<RecruitmentOpenResponseDto> retrieveOpenRecruitments() {
return retrieveRecruitmentPort.findByStatus(RecruitmentStatus.OPEN).stream()
.map(mapper::toOpenDto)
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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/**",
Expand Down

0 comments on commit 691c0e5

Please sign in to comment.