From db635dcedb9c01abed8237f6d74371770f734e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=A7=84?= <4mj.eo@dsm.hs.kr> Date: Wed, 6 Nov 2024 21:41:19 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=A0=20::=20(#830)=20=EA=B2=A8?= =?UTF-8?q?=EC=9A=B8=EC=9D=B8=ED=84=B4=20=EC=97=AC=EB=B6=80=EB=A1=9C=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jobis/domain/recruitment/spi/QueryRecruitmentPort.java | 1 - .../recruitment/usecase/CheckRecruitmentExistsUseCase.java | 4 ++-- .../persistence/RecruitmentPersistenceAdapter.java | 7 +------ .../persistence/repository/RecruitmentJpaRepository.java | 2 +- .../recruitment/presentation/RecruitmentWebAdapter.java | 7 +++++-- 5 files changed, 9 insertions(+), 12 deletions(-) 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..bf279ac9a 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 @@ -10,7 +10,7 @@ public class CheckRecruitmentExistsUseCase { private final RecruitmentPort recruitmentPort; - public boolean execute(Long companyId) { - return recruitmentPort.existsByCompanyId(companyId); + public boolean execute(Long companyId, boolean winterIntern) { + 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..95b23ee1b 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,7 +14,7 @@ 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); 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..d350bcb3a 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 @@ -253,8 +253,11 @@ public byte[] exportRecruitmentHistory(HttpServletResponse httpResponse) { } @GetMapping("/exists/{company-id}") - public boolean checkRecruitmentExists(@PathVariable("company-id") Long companyId) { - return checkRecruitmentExistsUseCase.execute(companyId); + public boolean checkRecruitmentExists( + @PathVariable("company-id") Long companyId, + @RequestParam(value = "winter_intern") Boolean winterIntern + ) { + return checkRecruitmentExistsUseCase.execute(companyId, winterIntern); } private List parseCodes(String jobCode, String techCodes) { From 849f77c3d7440ddd849a083a870267825ce722c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=A7=84?= <4mj.eo@dsm.hs.kr> Date: Wed, 6 Nov 2024 21:48:35 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9B=A0=20::=20(#830)=20getCurrentComp?= =?UTF-8?q?any=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/CheckRecruitmentExistsUseCase.java | 5 ++++- .../persistence/repository/RecruitmentJpaRepository.java | 1 - .../recruitment/presentation/RecruitmentWebAdapter.java | 9 +++------ .../team/retum/jobis/global/security/SecurityConfig.java | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) 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 bf279ac9a..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, boolean winterIntern) { + 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/repository/RecruitmentJpaRepository.java b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/RecruitmentJpaRepository.java index 95b23ee1b..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 @@ -19,5 +19,4 @@ public interface RecruitmentJpaRepository extends JpaRepository 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 d350bcb3a..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,12 +252,9 @@ public byte[] exportRecruitmentHistory(HttpServletResponse httpResponse) { return response.getFile(); } - @GetMapping("/exists/{company-id}") - public boolean checkRecruitmentExists( - @PathVariable("company-id") Long companyId, - @RequestParam(value = "winter_intern") Boolean winterIntern - ) { - return checkRecruitmentExistsUseCase.execute(companyId, winterIntern); + @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())