Skip to content

Commit

Permalink
[feat] 지원 서류 삭제 기능 (#177)
Browse files Browse the repository at this point in the history
* [feat] 지원 서류 삭제

* [chore] update CODEOWNERS
  • Loading branch information
hyunihs authored Jul 25, 2024
1 parent 52b0651 commit 8991643
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @hyunihs @suhhyun524 @mushroom1324 @haen-su @mirageoasis
* @hyunihs @mushroom1324 @letskuku @yoonsseo @itsme-shawn @YoungGyo-00
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
Expand Down Expand Up @@ -191,4 +183,11 @@ public GetCreationTime getApplicationExcelCreationTime() {
log.info("지원서 엑셀 파일 생성 시각 확인");
return applicationExcelService.getApplicationExcelCreationTime();
}

@Operation(summary = "지원서 전체 삭제")
@DeleteMapping(value = "/delete")
public void deleteAllApplications() {
log.info("지원서 전체 삭제");
applicationService.deleteAllApplications();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ApplicationAnswer extends BaseEntity {
private Long id;

// Question : Answer = 1:1 (단방향)
@OneToOne(cascade = CascadeType.ALL)
@OneToOne
@JoinColumn(name = "application_question_id")
private ApplicationQuestion applicationQuestion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum ApplicationErrorCode implements BaseErrorCode {
SAME_PASS_STATUS(BAD_REQUEST, "APPLICATION_400_7", "같은 상태로 변경할 수 없습니다."),
NOT_SET_INTERVIEW_TIME(BAD_REQUEST, "APPLICATION_400_8", "면접 시간이 정해지지 않았습니다."),
APPLICATION_STILL_EXIST(BAD_REQUEST, "APPLICATION_400_9", "기존 지원자 데이터가 남아있습니다."),
NOT_DELETABLE_DURING_RECRUITMENT(BAD_REQUEST, "APPLICATION_400_10", "최종 발표 전 지원자를 삭제할 수 없습니다."),

APPLICANT_NOT_FOUND(BAD_REQUEST, "APPLICATION_404_3", "존재하지 않는 지원자입니다."),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ceos.backend.domain.application.exception.exceptions;

import ceos.backend.domain.application.exception.ApplicationErrorCode;
import ceos.backend.global.error.BaseErrorException;

public class NotDeletableDuringRecruitment extends BaseErrorException {
public static final NotDeletableDuringRecruitment EXCEPTION = new NotDeletableDuringRecruitment();

private NotDeletableDuringRecruitment() {
super(ApplicationErrorCode.NOT_DELETABLE_DURING_RECRUITMENT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import ceos.backend.domain.application.dto.response.GetApplications;
import ceos.backend.domain.application.dto.response.GetInterviewTime;
import ceos.backend.domain.application.dto.response.GetResultResponse;
import ceos.backend.domain.application.exception.exceptions.NotDeletableDuringRecruitment;
import ceos.backend.domain.application.helper.ApplicationHelper;
import ceos.backend.domain.application.mapper.ApplicationMapper;
import ceos.backend.domain.application.repository.ApplicationAnswerRepository;
Expand All @@ -35,6 +36,8 @@
import ceos.backend.global.common.entity.Part;
import ceos.backend.global.util.InterviewDateTimeConvertor;
import ceos.backend.global.util.ParsedDurationConvertor;

import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -264,4 +267,16 @@ public void updateFinalPassStatus(Long applicationId, UpdatePassStatus updatePas

application.updateFinalPass(updatePassStatus.getPass());
}

@Transactional
public void deleteAllApplications() {
Recruitment recruitment = recruitmentHelper.takeRecruitment();
// 현재 시간이 resultDateFinal 이전이면 삭제 불가
if(LocalDateTime.now().isBefore(recruitment.getResultDateFinal())) {
throw NotDeletableDuringRecruitment.EXCEPTION;
}
// application, applicationAnswer, applicationInterview 삭제 (cascade)
applicationRepository.deleteAll();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Slf4j
@Service
@RequiredArgsConstructor
Expand All @@ -34,6 +36,7 @@ public UserRecruitmentDTO getUserRecruitment() {
@Transactional
public void updateRecruitment(RecruitmentDTO recruitmentDTO) {
Recruitment recruitment = recruitmentHelper.takeRecruitment();
recruitment.validAmenablePeriod(LocalDateTime.now());

// 객체 업데이트
recruitment.updateRecruitment(recruitmentDTO);
Expand Down

0 comments on commit 8991643

Please sign in to comment.