Skip to content

Commit 14b7a63

Browse files
committed
💄 style : 파라미터 네이밍 변경 thumbnailFile로 변경
1 parent e2d396c commit 14b7a63

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

backend/src/main/java/io/f1/backend/domain/quiz/api/QuizController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public class QuizController {
2828

2929
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
3030
public ResponseEntity<QuizCreateResponse> saveQuiz(
31-
@RequestPart(required = false) MultipartFile file,
31+
@RequestPart(required = false) MultipartFile thumbnailFile,
3232
@Valid @RequestPart QuizCreateRequest request)
3333
throws IOException {
34-
QuizCreateResponse response = quizService.saveQuiz(file, request);
34+
QuizCreateResponse response = quizService.saveQuiz(thumbnailFile, request);
3535

3636
return ResponseEntity.status(HttpStatus.CREATED).body(response);
3737
}

backend/src/main/java/io/f1/backend/domain/quiz/app/QuizService.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ public class QuizService {
4141
private final QuizRepository quizRepository;
4242

4343
@Transactional
44-
public QuizCreateResponse saveQuiz(MultipartFile file, QuizCreateRequest request)
44+
public QuizCreateResponse saveQuiz(MultipartFile thumbnailFile, QuizCreateRequest request)
4545
throws IOException {
4646
String thumbnailPath = defaultThumbnailPath;
4747

48-
if (file != null && !file.isEmpty()) {
49-
validateImageFile(file);
50-
thumbnailPath = convertToThumbnailPath(file);
48+
if (thumbnailFile != null && !thumbnailFile.isEmpty()) {
49+
validateImageFile(thumbnailFile);
50+
thumbnailPath = convertToThumbnailPath(thumbnailFile);
5151
}
5252

5353
// TODO : 시큐리티 구현 이후 삭제 (data.sql로 초기 저장해둔 유저 get), 나중엔 현재 로그인한 유저의 아이디를 받아오도록 수정
@@ -64,26 +64,26 @@ public QuizCreateResponse saveQuiz(MultipartFile file, QuizCreateRequest request
6464
return quizToQuizCreateResponse(savedQuiz);
6565
}
6666

67-
private void validateImageFile(MultipartFile file) {
67+
private void validateImageFile(MultipartFile thumbnailFile) {
6868

69-
if (!file.getContentType().startsWith("image")) {
69+
if (!thumbnailFile.getContentType().startsWith("image")) {
7070
// TODO : 이후 커스텀 예외로 변경
7171
throw new IllegalArgumentException("이미지 파일을 업로드해주세요.");
7272
}
7373

7474
List<String> allowedExt = List.of("jpg", "jpeg", "png", "webp");
75-
if (!allowedExt.contains(getExtension(file.getOriginalFilename()))) {
75+
if (!allowedExt.contains(getExtension(thumbnailFile.getOriginalFilename()))) {
7676
throw new IllegalArgumentException("지원하지 않는 확장자입니다.");
7777
}
7878
}
7979

80-
private String convertToThumbnailPath(MultipartFile file) throws IOException {
81-
String originalFilename = file.getOriginalFilename();
80+
private String convertToThumbnailPath(MultipartFile thumbnailFile) throws IOException {
81+
String originalFilename = thumbnailFile.getOriginalFilename();
8282
String ext = getExtension(originalFilename);
8383
String savedFilename = UUID.randomUUID().toString() + "." + ext;
8484

8585
Path savePath = Paths.get(uploadPath, savedFilename).toAbsolutePath();
86-
file.transferTo(savePath.toFile());
86+
thumbnailFile.transferTo(savePath.toFile());
8787

8888
return "/images/thumbnail/" + savedFilename;
8989
}

0 commit comments

Comments
 (0)