Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”— :: (#830) ๊ฒจ์šธ์ธํ„ด ์—ฌ๋ถ€๋กœ ํ™•์ธ #831

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading