From 45e48a0f73898e5aa068e5fce5cc1207ac9d24e7 Mon Sep 17 00:00:00 2001 From: unanchoi Date: Mon, 15 Jan 2024 22:02:00 +0900 Subject: [PATCH] =?UTF-8?q?[CHORE]=20=EC=9D=B8=ED=84=B0=EB=B7=B0=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InterviewController.java | 11 ++++++----- .../repository/InterviewJpaRepository.java | 11 ----------- ...viewService.java => GraduateInterviewService.java} | 10 ++++------ .../service/InterviewFileUploadService.java | 4 ++-- 4 files changed, 12 insertions(+), 24 deletions(-) delete mode 100644 src/main/java/com/startlion/startlionserver/repository/InterviewJpaRepository.java rename src/main/java/com/startlion/startlionserver/service/{InterviewService.java => GraduateInterviewService.java} (90%) diff --git a/src/main/java/com/startlion/startlionserver/controller/InterviewController.java b/src/main/java/com/startlion/startlionserver/controller/InterviewController.java index 22a06df..b2d549b 100644 --- a/src/main/java/com/startlion/startlionserver/controller/InterviewController.java +++ b/src/main/java/com/startlion/startlionserver/controller/InterviewController.java @@ -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; @@ -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> getInterviews(@RequestParam(required = false) String part) { - val response = interviewService.getInterviews(part); + public ResponseEntity> getInterviews( + @RequestParam(required = false) String part) { + val response = graduateInterviewService.getInterviews(part); return ResponseEntity.ok(response); } @GetMapping("/{interviewId}") public ResponseEntity getInterviewById(@PathVariable Long interviewId) { - val response = interviewService.getInterviewById(interviewId); + val response = graduateInterviewService.getInterviewById(interviewId); return ResponseEntity.ok(response); } } diff --git a/src/main/java/com/startlion/startlionserver/repository/InterviewJpaRepository.java b/src/main/java/com/startlion/startlionserver/repository/InterviewJpaRepository.java deleted file mode 100644 index aac9310..0000000 --- a/src/main/java/com/startlion/startlionserver/repository/InterviewJpaRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.startlion.startlionserver.repository; - -import com.startlion.startlionserver.domain.entity.GraduateInterview; -import com.startlion.startlionserver.domain.enums.IntervieweePart; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.List; - -public interface InterviewJpaRepository extends JpaRepository { - List findAllByPart(IntervieweePart part); -} diff --git a/src/main/java/com/startlion/startlionserver/service/InterviewService.java b/src/main/java/com/startlion/startlionserver/service/GraduateInterviewService.java similarity index 90% rename from src/main/java/com/startlion/startlionserver/service/InterviewService.java rename to src/main/java/com/startlion/startlionserver/service/GraduateInterviewService.java index d3d7dbb..bab09bc 100644 --- a/src/main/java/com/startlion/startlionserver/service/InterviewService.java +++ b/src/main/java/com/startlion/startlionserver/service/GraduateInterviewService.java @@ -7,7 +7,6 @@ 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; @@ -15,20 +14,19 @@ 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) @@ -37,7 +35,7 @@ public InterviewDetailResponse getInterviewById(Long interviewId) { } public List getInterviews(String part) { - if (part == "ALL") { + if (Objects.equals(part, "ALL")) { return graduateInterviewJpaRepository.findAll().stream() .map(InterviewResponse::of) .collect(Collectors.toList()); diff --git a/src/main/java/com/startlion/startlionserver/service/InterviewFileUploadService.java b/src/main/java/com/startlion/startlionserver/service/InterviewFileUploadService.java index a709b28..08782c9 100644 --- a/src/main/java/com/startlion/startlionserver/service/InterviewFileUploadService.java +++ b/src/main/java/com/startlion/startlionserver/service/InterviewFileUploadService.java @@ -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("파일 업로드에 실패했습니다."); }