Skip to content

Commit

Permalink
๐Ÿ”— :: (#830) ๊ฒจ์šธ์ธํ„ด ์—ฌ๋ถ€๋กœ ํ™•์ธ
Browse files Browse the repository at this point in the history
  • Loading branch information
4mjeo authored Nov 6, 2024
2 parents 247de68 + 849f77c commit 9ce5497
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ public interface QueryRecruitmentPort {

List<Recruitment> getRecent();

boolean existsByCompanyId(Long companyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

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
@ReadOnlyUseCase
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public List<Recruitment> getAllByIdInOrThrow(List<Long> recruitmentIds) {

@Override
public boolean existsByCompanyIdAndWinterIntern(Long companyId, boolean winterIntern) {
return recruitmentJpaRepository.existsByCompanyIdAndStatusNotAndWinterIntern(companyId, RecruitStatus.DONE, winterIntern);
return recruitmentJpaRepository.existsByCompanyIdAndWinterIntern(companyId, winterIntern);
}

@Override
Expand Down Expand Up @@ -401,11 +401,6 @@ public List<Recruitment> getRecent() {
return recruitmentJpaRepository.findByCreationDateBetween(oneDayAgo, now);
}

@Override
public boolean existsByCompanyId(Long companyId) {
return recruitmentJpaRepository.existsByCompanyId(companyId);
}

//===conditions===//

private BooleanExpression eqYear(Integer year) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ public interface RecruitmentJpaRepository extends JpaRepository<RecruitmentEntit

List<RecruitmentEntity> findByIdIn(List<Long> 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<Recruitment> findByCreationDateBetween(@Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate);

boolean existsByCompanyId(Long companyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> parseCodes(String jobCode, String techCodes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 9ce5497

Please sign in to comment.