Skip to content

Commit

Permalink
Merge pull request #62 from LetsCareer-A/feat/#61
Browse files Browse the repository at this point in the history
#61 [feat] 4.4 면접 전형 상세 조회 기능 구현
  • Loading branch information
oosedus authored Sep 3, 2024
2 parents e35ddcf + 38a616e commit e8dd5ce
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum ErrorCode {
STAGE_NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, "해당 ID의 전형 단계를 찾을 수 없습니다."),
DOC_STAGE_NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, "해당 ID의 서류전형 단계를 찾을 수 없습니다."),
MID_STAGE_NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, "해당 ID의 중간전형 단계를 찾을 수 없습니다."),
INT_STAGE_NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, "해당 ID의 면접전형 단계를 찾을 수 없습니다."),
// 405 METHOD_NOT_ALLOWED
METHOD_NOT_ALLOWED_EXCEPTION(HttpStatus.METHOD_NOT_ALLOWED, "지원하지 않는 메소드 입니다."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public enum SuccessCode {
UPDATE_SCHEDULE_PROGRESS_SUCCESS(HttpStatus.OK, "일정 진행 상태 변경 성공"),
STAGES_GET_SUCCESS(HttpStatus.OK, "지원 일정 및 단계 조회 성공"),
DOC_STAGES_GET_SUCCESS(HttpStatus.OK, "서류전형 단계 조회 성공"),
MID_STAGES_GET_SUCCESS(HttpStatus.OK, "중간전형 단계 조회 성공"),;
MID_STAGES_GET_SUCCESS(HttpStatus.OK, "중간전형 단계 조회 성공"),
INT_STAGES_GET_SUCCESS(HttpStatus.OK, "면접전형 단계 조회 성공"),;

private final HttpStatus httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public interface IntReviewRepository extends JpaRepository<IntReview, Long> {
@Query("SELECT ir.intReviewId FROM IntReview ir WHERE ir.stage = :stage AND ir.user = :user")
Optional<Long> findIntReviewIdByStageAndUser(Stage stage, User user);
Optional<IntReview> findByIntReviewIdAndUser(Long intReviewId, User user);

Optional<IntReview> findByStage(Stage stage);
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,17 @@ public ApiResponse getMidStage(
return ErrorResponse.error(e.getErrorCode());
}
}

@GetMapping("/schedules/{scheduleId}/stages/{stageId}/interview")
public ApiResponse getInterviewStage(
@RequestHeader("userId") Long userId,
@PathVariable Long scheduleId,
@PathVariable Long stageId
) {
try {
return SuccessResponse.success(SuccessCode.INT_STAGES_GET_SUCCESS , stageService.getInterviewStage(userId, scheduleId, stageId));
} catch (NotFoundException | BadRequestException e) {
return ErrorResponse.error(e.getErrorCode());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.letscareer.stage.dto;

public record IntReviewDTO(
Long reviewId,
String details,
String qa,
String feel
) {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.example.letscareer.stage.dto;

import java.time.LocalDate;

public record ReviewDTO(
public record MidReviewDTO(
Long reviewId,
String free_review,
String goal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.letscareer.stage.dto.response;

import com.example.letscareer.stage.dto.AppealCareerDTO;
import com.example.letscareer.stage.dto.IntReviewDTO;

import java.util.List;

public record GetInterviewStageResponse(
boolean reviewAvailable,
IntReviewDTO review,
List<AppealCareerDTO> appealCareers
) {
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.example.letscareer.stage.dto.response;

import com.example.letscareer.stage.dto.ReviewDTO;
import com.example.letscareer.stage.dto.MidReviewDTO;

public record GetMidStageResponse(
boolean reviewAvailable,
ReviewDTO review
MidReviewDTO review
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.example.letscareer.appealCareer.domain.AppealCareer;
import com.example.letscareer.appealCareer.repository.AppealCareerRepository;
import com.example.letscareer.common.exception.model.NotFoundException;
import com.example.letscareer.int_review.domain.IntReview;
import com.example.letscareer.int_review.repository.IntReviewRepository;
import com.example.letscareer.mid_review.domain.MidReview;
import com.example.letscareer.mid_review.repository.MidReviewRepository;
import com.example.letscareer.schedule.domain.Schedule;
Expand All @@ -14,14 +16,12 @@
import com.example.letscareer.stage.domain.Status;
import com.example.letscareer.stage.domain.Type;
import com.example.letscareer.stage.dto.AppealCareerDTO;
import com.example.letscareer.stage.dto.ReviewDTO;
import com.example.letscareer.stage.dto.IntReviewDTO;
import com.example.letscareer.stage.dto.MidReviewDTO;
import com.example.letscareer.stage.dto.StageDTO;
import com.example.letscareer.stage.dto.request.AddStageRequest;
import com.example.letscareer.stage.dto.request.UpdateStageStatusRequest;
import com.example.letscareer.stage.dto.response.AddStageResponse;
import com.example.letscareer.stage.dto.response.GetDocumentStageResponse;
import com.example.letscareer.stage.dto.response.GetMidStageResponse;
import com.example.letscareer.stage.dto.response.GetStagesResponse;
import com.example.letscareer.stage.dto.response.*;
import com.example.letscareer.stage.repository.StageRepository;
import com.example.letscareer.user.domain.User;
import com.example.letscareer.user.repository.UserRepository;
Expand Down Expand Up @@ -49,6 +49,7 @@ public class StageService {
private final SelfIntroRepository selfIntroRepository;
private final AppealCareerRepository appealCareerRepository;
private final MidReviewRepository midReviewRepository;
private final IntReviewRepository intReviewRepository;

@Transactional
public AddStageResponse addStage(Long userId, Long scheduleId, AddStageRequest request) {
Expand Down Expand Up @@ -154,17 +155,13 @@ public GetDocumentStageResponse getDocumentStage(Long userId, Long scheduleId, L
);
}

List<AppealCareer> appealCareers = appealCareerRepository.findByStage(stage);
List<AppealCareerDTO> appealCareerDTOs = new ArrayList<>();
for(AppealCareer appealCareer : appealCareers) {
appealCareerDTOs.add(
new AppealCareerDTO(
appealCareer.getCareer().getCareerId(),
appealCareer.getCareer().getCategory().getValue(),
appealCareer.getCareer().getTitle()
)
);
}
List<AppealCareerDTO> appealCareerDTOs = appealCareerRepository.findByStage(stage).stream()
.map(appealCareer -> new AppealCareerDTO(
appealCareer.getCareer().getCareerId(),
appealCareer.getCareer().getCategory().getValue(),
appealCareer.getCareer().getTitle()
))
.toList();

return new GetDocumentStageResponse(
stage.getStageId(),
Expand All @@ -191,15 +188,45 @@ public GetMidStageResponse getMidStage(Long userId, Long scheduleId, Long stageI
);
}
else {
ReviewDTO reviewDTO = new ReviewDTO(
MidReviewDTO midReviewDTO = new MidReviewDTO(
midReview.get().getMidReviewId(),
midReview.get().getFreeReview(),
midReview.get().getGoal()
);
return new GetMidStageResponse(
false,
reviewDTO
midReviewDTO
);
}
}
}

public GetInterviewStageResponse getInterviewStage(Long userId, Long scheduleId, Long stageId) {
User user = userRepository.findById(userId)
.orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));
Schedule schedule = scheduleRepository.findByUserAndScheduleId(user, scheduleId)
.orElseThrow(() -> new NotFoundException(SCHEDULE_NOT_FOUND_EXCEPTION));
Stage stage = stageRepository.findByScheduleAndStageIdAndType(schedule, stageId, Type.INT)
.orElseThrow(() -> new NotFoundException(INT_STAGE_NOT_FOUND_EXCEPTION));

List<AppealCareerDTO> appealCareerDTOs = appealCareerRepository.findByStage(stage).stream()
.map(appealCareer -> new AppealCareerDTO(
appealCareer.getCareer().getCareerId(),
appealCareer.getCareer().getCategory().getValue(),
appealCareer.getCareer().getTitle()
))
.toList();

Optional<IntReview> intReview = intReviewRepository.findByStage(stage);

return new GetInterviewStageResponse(
intReview.isPresent(),
intReview.map(ir -> new IntReviewDTO(
ir.getIntReviewId(),
ir.getMethod(),
ir.getQuestions(),
ir.getFeelings()
)).orElse(null),
appealCareerDTOs
);
}
}

0 comments on commit e8dd5ce

Please sign in to comment.