diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/spi/QueryRecruitmentPort.java b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/spi/QueryRecruitmentPort.java index d68900d07..17110e817 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/spi/QueryRecruitmentPort.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/spi/QueryRecruitmentPort.java @@ -38,5 +38,4 @@ public interface QueryRecruitmentPort { List getRecent(); - boolean existsByCompanyId(Long companyId); } diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/usecase/CheckRecruitmentExistsUseCase.java b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/usecase/CheckRecruitmentExistsUseCase.java index b40e4bb9c..4c7a1b039 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/usecase/CheckRecruitmentExistsUseCase.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/usecase/CheckRecruitmentExistsUseCase.java @@ -2,6 +2,7 @@ import lombok.RequiredArgsConstructor; import team.retum.jobis.common.annotation.ReadOnlyUseCase; +import team.retum.jobis.common.spi.SecurityPort; import team.retum.jobis.domain.recruitment.spi.RecruitmentPort; @RequiredArgsConstructor @@ -9,8 +10,10 @@ public class CheckRecruitmentExistsUseCase { private final RecruitmentPort recruitmentPort; + private final SecurityPort securityPort; - public boolean execute(Long companyId) { - return recruitmentPort.existsByCompanyId(companyId); + public boolean execute(boolean winterIntern) { + Long companyId = securityPort.getCurrentCompany().getId(); + return recruitmentPort.existsByCompanyIdAndWinterIntern(companyId, winterIntern); } } diff --git a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/RecruitmentPersistenceAdapter.java b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/RecruitmentPersistenceAdapter.java index 906e6760c..478d4eae6 100644 --- a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/RecruitmentPersistenceAdapter.java +++ b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/RecruitmentPersistenceAdapter.java @@ -364,7 +364,7 @@ public List getAllByIdInOrThrow(List recruitmentIds) { @Override public boolean existsByCompanyIdAndWinterIntern(Long companyId, boolean winterIntern) { - return recruitmentJpaRepository.existsByCompanyIdAndStatusNotAndWinterIntern(companyId, RecruitStatus.DONE, winterIntern); + return recruitmentJpaRepository.existsByCompanyIdAndWinterIntern(companyId, winterIntern); } @Override @@ -401,11 +401,6 @@ public List getRecent() { return recruitmentJpaRepository.findByCreationDateBetween(oneDayAgo, now); } - @Override - public boolean existsByCompanyId(Long companyId) { - return recruitmentJpaRepository.existsByCompanyId(companyId); - } - //===conditions===// private BooleanExpression eqYear(Integer year) { diff --git a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/RecruitmentJpaRepository.java b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/RecruitmentJpaRepository.java index 484ca16c5..edcb421c8 100644 --- a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/RecruitmentJpaRepository.java +++ b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/RecruitmentJpaRepository.java @@ -14,10 +14,9 @@ public interface RecruitmentJpaRepository extends JpaRepository findByIdIn(List recruitmentIds); - boolean existsByCompanyIdAndStatusNotAndWinterIntern(Long companyId, RecruitStatus status, boolean winterIntern); + boolean existsByCompanyIdAndWinterIntern(Long companyId, boolean winterIntern); @Query("SELECT r FROM RecruitmentEntity r WHERE r.createdAt BETWEEN :startDate AND :endDate") List findByCreationDateBetween(@Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate); - boolean existsByCompanyId(Long companyId); } diff --git a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/presentation/RecruitmentWebAdapter.java b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/presentation/RecruitmentWebAdapter.java index b6efae05b..fb22b34eb 100644 --- a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/presentation/RecruitmentWebAdapter.java +++ b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/presentation/RecruitmentWebAdapter.java @@ -252,9 +252,9 @@ public byte[] exportRecruitmentHistory(HttpServletResponse httpResponse) { return response.getFile(); } - @GetMapping("/exists/{company-id}") - public boolean checkRecruitmentExists(@PathVariable("company-id") Long companyId) { - return checkRecruitmentExistsUseCase.execute(companyId); + @GetMapping("/exists") + public boolean checkRecruitmentExists(@RequestParam(value = "winter_intern") Boolean winterIntern) { + return checkRecruitmentExistsUseCase.execute(winterIntern); } private List parseCodes(String jobCode, String techCodes) { diff --git a/jobis-infrastructure/src/main/java/team/retum/jobis/global/security/SecurityConfig.java b/jobis-infrastructure/src/main/java/team/retum/jobis/global/security/SecurityConfig.java index e18682f92..0bc7ad1fa 100644 --- a/jobis-infrastructure/src/main/java/team/retum/jobis/global/security/SecurityConfig.java +++ b/jobis-infrastructure/src/main/java/team/retum/jobis/global/security/SecurityConfig.java @@ -60,7 +60,7 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .requestMatchers(HttpMethod.DELETE, "/recruitments/area/{recruit-area-id}").hasAnyAuthority(TEACHER.name(), COMPANY.name()) .requestMatchers(HttpMethod.GET, "/recruitments/file").hasAuthority(TEACHER.name()) .requestMatchers(HttpMethod.GET, "/recruitments/count").hasAnyAuthority(TEACHER.name()) - .requestMatchers(HttpMethod.GET, "/recruitments/exists/{company-id}").hasAnyAuthority(COMPANY.name()) + .requestMatchers(HttpMethod.GET, "/recruitments/exists").hasAnyAuthority(COMPANY.name()) // bugs .requestMatchers(HttpMethod.GET, "/bugs").hasAuthority(DEVELOPER.name())