-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] 면접 예약 API 구현 #55
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
94eb07c
feat: 면접 예약 API 구현
hodoon 6b966e8
feat: 면접 예약 API InterviewSlotRepository 쿼리 추가
hodoon 3c98cc7
feat: 면접 예약 API
hodoon 83a5012
Merge branch 'dev' into feat/#45-1
hodoon 79fb59c
fix: 면접 예약 API 수정 완료
hodoon 881c958
Merge branch 'feat/#45-1' of https://github.com/DASOM-GitHub/dasom-we…
hodoon 438fc5c
feat: Google Credentials 주입 방식 파일이 아닌 JSON 값으로 받도록 수정
ysw789 be79688
chore: .gitignore 적용되지 않는 항목 제거
ysw789 e54c4cb
Merge remote-tracking branch 'origin/feat/#45-1' into feat/#45-1
ysw789 051c4a4
fix: 면접 예약 API 수정 완료
hodoon caf2c7a
fix: 면접 예약 API 수정 완료
hodoon ba34fa7
fix: 면접 예약 API 수정 완료
hodoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/dmu/dasom/api/domain/interview/dto/InterviewReservationRequestDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package dmu.dasom.api.domain.interview.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import lombok.*; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class InterviewReservationRequestDto { | ||
|
|
||
| @NotNull(message = "슬롯 ID는 필수 값입니다.") | ||
| private Long slotId; // 예약할 슬롯 ID | ||
|
|
||
| @NotNull(message = "예약 코드는 필수 값입니다.") | ||
| @Pattern(regexp = "^[0-9]{8}[0-9]{4}$", message = "예약 코드는 학번 전체와 전화번호 뒤 4자리로 구성되어야 합니다.") | ||
| private String reservationCode; // 학번 전체 + 전화번호 뒤 4자리 조합 코드 | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
src/main/java/dmu/dasom/api/domain/interview/dto/InterviewReservationResponseDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package dmu.dasom.api.domain.interview.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.*; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class InterviewReservationResponseDto { | ||
|
|
||
| @NotNull(message = "예약 ID는 필수 값입니다.") | ||
| private Long reservationId; // 예약 ID | ||
|
|
||
| @NotNull(message = "슬롯 ID는 필수 값입니다.") | ||
| private Long slotId; // 슬롯 ID | ||
|
|
||
| @NotNull(message = "지원자 ID는 필수 값입니다.") | ||
| private Long applicantId; // 지원자 ID | ||
|
|
||
| @NotNull(message = "예약 코드는 필수 값입니다.") | ||
| private String reservationCode; // 예약 코드 (학번+전화번호 조합) | ||
|
|
||
| } |
27 changes: 27 additions & 0 deletions
27
src/main/java/dmu/dasom/api/domain/interview/dto/InterviewSlotCreateRequestDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package dmu.dasom.api.domain.interview.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.*; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class InterviewSlotCreateRequestDto { | ||
|
|
||
| @NotNull(message = "시작 날짜는 필수 값입니다.") | ||
| private LocalDate startDate; // 면접 시작 날짜 | ||
|
|
||
| @NotNull(message = "종료 날짜는 필수 값입니다.") | ||
| private LocalDate endDate; // 면접 종료 날짜 | ||
|
|
||
| @NotNull(message = "시작 시간은 필수 값입니다.") | ||
| private LocalTime startTime; // 하루의 시작 시간 | ||
|
|
||
| @NotNull(message = "종료 시간은 필수 값입니다.") | ||
| private LocalTime endTime; // 하루의 종료 시간 | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/main/java/dmu/dasom/api/domain/interview/dto/InterviewSlotRequestDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package dmu.dasom.api.domain.interview.dto; | ||
|
|
||
| import jakarta.validation.constraints.Max; | ||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.*; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class InterviewSlotRequestDto { | ||
|
|
||
| @NotNull(message = "면접 날짜는 필수 입력 값입니다.") | ||
| private LocalDate interviewDate; // 면접 날짜 | ||
|
|
||
| @NotNull(message = "시작 시간은 필수 입력 값입니다.") | ||
| private LocalTime startTime; // 시작 시간 | ||
|
|
||
| @NotNull(message = "종료 시간은 필수 입력 값입니다.") | ||
| private LocalTime endTime; // 종료 시간 | ||
|
|
||
| @NotNull(message = "최대 지원자 수는 필수 입력 값입니다.") | ||
| @Min(value = 1, message = "최대 지원자 수는 최소 1명 이상이어야 합니다.") | ||
| @Max(value = 100, message = "최대 지원자 수는 최대 100명까지 가능합니다.") // 필요에 따라 수정 가능 | ||
| private Integer maxCandidates; // 최대 지원자 수 | ||
| } |
49 changes: 49 additions & 0 deletions
49
src/main/java/dmu/dasom/api/domain/interview/dto/InterviewSlotResponseDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package dmu.dasom.api.domain.interview.dto; | ||
|
|
||
| import dmu.dasom.api.domain.interview.entity.InterviewSlot; | ||
| import jakarta.validation.constraints.Max; | ||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.*; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class InterviewSlotResponseDto { | ||
|
|
||
| @NotNull(message = "슬롯 ID는 필수 입력 값입니다.") | ||
| private Long id; // 슬롯 ID | ||
|
|
||
| @NotNull(message = "면접 날짜는 필수 입력 값입니다.") | ||
| private LocalDate interviewDate; // 면접 날짜 | ||
|
|
||
| @NotNull(message = "시작 시간은 필수 입력 값입니다.") | ||
| private LocalTime startTime; // 시작 시간 | ||
|
|
||
| @NotNull(message = "종료 시간은 필수 입력 값입니다.") | ||
| private LocalTime endTime; // 종료 시간 | ||
|
|
||
| @NotNull(message = "최대 지원자 수는 필수 입력 값입니다.") | ||
| @Min(value = 1, message = "최대 지원자 수는 최소 1명 이상이어야 합니다.") | ||
| @Max(value = 100, message = "최대 지원자 수는 최대 100명까지 가능합니다.") | ||
| private Integer maxCandidates; // 최대 지원자 수 | ||
|
|
||
| @NotNull(message = "현재 예약된 지원자 수는 필수 입력 값입니다.") | ||
| @Min(value = 0, message = "현재 예약된 지원자 수는 0명 이상이어야 합니다.") | ||
| private Integer currentCandidates; // 현재 예약된 지원자 수 | ||
|
|
||
| public InterviewSlotResponseDto(InterviewSlot slot){ | ||
| this.id = slot.getId(); | ||
| this.interviewDate = slot.getInterviewDate(); | ||
| this.startTime = slot.getStartTime(); | ||
| this.endTime = slot.getEndTime(); | ||
| this.maxCandidates = slot.getMaxCandidates(); | ||
| this.currentCandidates = slot.getCurrentCandidates(); | ||
| } | ||
|
|
||
| } |
29 changes: 29 additions & 0 deletions
29
src/main/java/dmu/dasom/api/domain/interview/entity/InterviewReservation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package dmu.dasom.api.domain.interview.entity; | ||
|
|
||
| import dmu.dasom.api.domain.applicant.entity.Applicant; | ||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class InterviewReservation { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "slot_id", nullable = false) | ||
| private InterviewSlot slot; // 연관된 면접 슬롯 | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "applicant_id", nullable = false) | ||
| private Applicant applicant; // 지원자 | ||
|
|
||
| @Column(nullable = false, unique = true, length = 12) | ||
| private String reservationCode; // 학번 전체 + 전화번호 뒤 4자리 조합 코드 | ||
| } |
54 changes: 54 additions & 0 deletions
54
src/main/java/dmu/dasom/api/domain/interview/entity/InterviewSlot.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package dmu.dasom.api.domain.interview.entity; | ||
|
|
||
| import dmu.dasom.api.domain.interview.enums.InterviewStatus; | ||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class InterviewSlot { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false) | ||
| private LocalDate interviewDate; | ||
|
|
||
| @Column(nullable = false) | ||
| private LocalTime startTime; | ||
|
|
||
| @Column(nullable = false) | ||
| private LocalTime endTime; // 종료 시간 | ||
|
|
||
| @Column(nullable = false) | ||
| private Integer maxCandidates; // 최대 지원자 수 | ||
|
|
||
| @Column(nullable = false) | ||
| private Integer currentCandidates; // 현재 예약된 지원자 수 | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(nullable = false, length = 16) | ||
| private InterviewStatus interviewStatus; // 면접 슬롯 상태 (ACTIVE, INACTIVE, CLOSED) | ||
|
|
||
| public void incrementCurrentCandidates() { | ||
| this.currentCandidates++; | ||
| if (this.currentCandidates >= this.maxCandidates) { | ||
| this.interviewStatus = InterviewStatus.CLOSED; // 최대 지원자 수에 도달하면 상태 변경 | ||
| } | ||
| } | ||
|
|
||
| public void decrementCurrentCandidates() { | ||
| this.currentCandidates--; | ||
| if (interviewStatus == InterviewStatus.CLOSED && this.currentCandidates < this.maxCandidates) { | ||
| this.interviewStatus = InterviewStatus.ACTIVE; // 지원자 수가 줄어들면 다시 활성화 | ||
| } | ||
| } | ||
|
|
||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/dmu/dasom/api/domain/interview/enums/InterviewStatus.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package dmu.dasom.api.domain.interview.enums; | ||
|
|
||
| public enum InterviewStatus { | ||
| ACTIVE, // 활성화된 슬롯 | ||
| INACTIVE, // 비활성화된 슬롯 | ||
| CLOSED // 예약 마감된 슬롯 | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/dmu/dasom/api/domain/interview/repositoty/InterviewReservationRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package dmu.dasom.api.domain.interview.repositoty; | ||
|
|
||
| import dmu.dasom.api.domain.interview.entity.InterviewReservation; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public interface InterviewReservationRepository extends JpaRepository<InterviewReservation, Long> { | ||
| boolean existsByReservationCode(String reservationCode); | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/main/java/dmu/dasom/api/domain/interview/repositoty/InterviewSlotRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package dmu.dasom.api.domain.interview.repositoty; | ||
|
|
||
| import dmu.dasom.api.domain.interview.entity.InterviewSlot; | ||
| import dmu.dasom.api.domain.interview.enums.InterviewStatus; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| @Repository | ||
| public interface InterviewSlotRepository extends JpaRepository<InterviewSlot, Long> { | ||
| // 현재 인원이 최대 인원보다 작은 슬롯 조회 | ||
| // 현재 예약된 인원이 최대 지원자 수보다 적은 슬롯 조회 | ||
| @Query("SELECT s FROM InterviewSlot s WHERE s.currentCandidates < s.maxCandidates") | ||
| Collection<InterviewSlot> findAllByCurrentCandidatesLessThanMaxCandidates(); | ||
|
|
||
| // 상태에 따른 슬롯 조회 | ||
| @Query("SELECT s FROM InterviewSlot s WHERE s.interviewStatus = :status AND s.currentCandidates < s.maxCandidates") | ||
| List<InterviewSlot> findAllByStatusAndCurrentCandidatesLessThanMaxCandidates(InterviewStatus interviewStatus); | ||
|
|
||
| // 슬롯이 하나라도 존재하는지 확인 | ||
| @Query("SELECT COUNT(s) > 0 FROM InterviewSlot s") | ||
| boolean existsAny(); | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/main/java/dmu/dasom/api/domain/interview/service/InterviewService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package dmu.dasom.api.domain.interview.service; | ||
|
|
||
| import dmu.dasom.api.domain.interview.dto.InterviewReservationRequestDto; | ||
| import dmu.dasom.api.domain.interview.dto.InterviewSlotResponseDto; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalTime; | ||
| import java.util.List; | ||
|
|
||
|
|
||
| public interface InterviewService { | ||
|
|
||
| // 면접 슬롯 생성 | ||
| List<InterviewSlotResponseDto> createInterviewSlots(LocalDate newStartDate, LocalDate newEndDate, LocalTime newStartTime, LocalTime newEndTime); | ||
|
|
||
| // 예약 가능한 면접 슬롯 조회 | ||
| List<InterviewSlotResponseDto> getAvailableSlots(); | ||
|
|
||
| // 면접 예약 | ||
| void reserveInterviewSlot(InterviewReservationRequestDto request); | ||
|
|
||
| // 면접 예약 취소 | ||
| void cancelReservation(Long reservationId, Long applicantId); | ||
|
|
||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.