Skip to content

Commit

Permalink
[CHORE] 인터뷰 목록 조회 API 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Jan 15, 2024
1 parent 30d51da commit 45e48a0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.startlion.startlionserver.controller.swagger.InterviewApi;
import com.startlion.startlionserver.dto.response.interview.InterviewDetailResponse;
import com.startlion.startlionserver.dto.response.interview.InterviewResponse;
import com.startlion.startlionserver.service.InterviewService;
import com.startlion.startlionserver.service.GraduateInterviewService;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.http.ResponseEntity;
Expand All @@ -17,19 +17,20 @@
@RequestMapping("/api/interviews")
public class InterviewController implements InterviewApi {

private final InterviewService interviewService;
private final GraduateInterviewService graduateInterviewService;


// ALL, DEV, DESIGN, BE, FE, PM
@GetMapping
public ResponseEntity<List<InterviewResponse>> getInterviews(@RequestParam(required = false) String part) {
val response = interviewService.getInterviews(part);
public ResponseEntity<List<InterviewResponse>> getInterviews(
@RequestParam(required = false) String part) {
val response = graduateInterviewService.getInterviews(part);
return ResponseEntity.ok(response);
}

@GetMapping("/{interviewId}")
public ResponseEntity<InterviewDetailResponse> getInterviewById(@PathVariable Long interviewId) {
val response = interviewService.getInterviewById(interviewId);
val response = graduateInterviewService.getInterviewById(interviewId);
return ResponseEntity.ok(response);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,26 @@
import com.startlion.startlionserver.dto.response.interviewanswer.InterviewAnswerResponse;
import com.startlion.startlionserver.repository.GraduateInterviewContentJpaRepository;
import com.startlion.startlionserver.repository.GraduateInterviewJpaRepository;
import com.startlion.startlionserver.repository.InterviewQueryRepository;
import jakarta.persistence.EntityNotFoundException;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class InterviewService {
public class GraduateInterviewService {

private final GraduateInterviewJpaRepository graduateInterviewJpaRepository;
private final GraduateInterviewContentJpaRepository graduateInterviewContentJpaRepository;
private final InterviewQueryRepository interviewQueryRepository;

public InterviewDetailResponse getInterviewById(Long interviewId) {
val interview = getById(interviewId);

val interview = getById(interviewId);
val interviewAnswerResponses = graduateInterviewContentJpaRepository.findByGraduateInterview(interview)
.stream()
.map(InterviewAnswerResponse::of)
Expand All @@ -37,7 +35,7 @@ public InterviewDetailResponse getInterviewById(Long interviewId) {
}

public List<InterviewResponse> getInterviews(String part) {
if (part == "ALL") {
if (Objects.equals(part, "ALL")) {
return graduateInterviewJpaRepository.findAll().stream()
.map(InterviewResponse::of)
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
public class InterviewFileUploadService {

private final S3Service s3Service;
private final InterviewService interviewService;
private final GraduateInterviewService graduateInterviewService;

public void uploadFile(MultipartFile file, Long interviewId) {
try {
val fileName = generateFileName();
val imageUrl = s3Service.upload(fileName, file);
interviewService.updateInterviewImageUrl(interviewId, imageUrl);
graduateInterviewService.updateInterviewImageUrl(interviewId, imageUrl);
} catch (RuntimeException | IOException e) {
throw new RuntimeException("파일 업로드에 실패했습니다.");
}
Expand Down

0 comments on commit 45e48a0

Please sign in to comment.