diff --git a/src/main/java/com/moabam/api/application/image/ImageService.java b/src/main/java/com/moabam/api/application/image/ImageService.java index adabbf27..a70a783f 100644 --- a/src/main/java/com/moabam/api/application/image/ImageService.java +++ b/src/main/java/com/moabam/api/application/image/ImageService.java @@ -1,5 +1,7 @@ package com.moabam.api.application.image; +import static com.moabam.global.error.model.ErrorMessage.IMAGE_CONVERT_FAIL; + import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -14,6 +16,7 @@ import com.moabam.api.domain.image.NewImage; import com.moabam.api.dto.room.CertifyRoomsRequest; import com.moabam.api.infrastructure.s3.S3Manager; +import com.moabam.global.error.exception.BadRequestException; import lombok.RequiredArgsConstructor; @@ -42,12 +45,13 @@ public List uploadImages(List multipartFiles, I } public List getNewImages(CertifyRoomsRequest request) { - return request.certifyRoomsRequest().stream() - .map(c -> { + return request.getCertifyRoomsRequest().stream() + .map(certifyRoomRequest -> { try { - return NewImage.of(c.routineId().toString(), c.image().getContentType(), c.image().getBytes()); + return NewImage.of(String.valueOf(certifyRoomRequest.getRoutineId()), + certifyRoomRequest.getImage().getContentType(), certifyRoomRequest.getImage().getBytes()); } catch (IOException e) { - throw new RuntimeException(e); + throw new BadRequestException(IMAGE_CONVERT_FAIL); } }) .toList(); diff --git a/src/main/java/com/moabam/api/dto/room/CertifyRoomRequest.java b/src/main/java/com/moabam/api/dto/room/CertifyRoomRequest.java index 7ef3496a..594942e4 100644 --- a/src/main/java/com/moabam/api/dto/room/CertifyRoomRequest.java +++ b/src/main/java/com/moabam/api/dto/room/CertifyRoomRequest.java @@ -2,12 +2,13 @@ import org.springframework.web.multipart.MultipartFile; -import lombok.Builder; +import lombok.Getter; +import lombok.Setter; -@Builder -public record CertifyRoomRequest( - Long routineId, - MultipartFile image -) { +@Getter +@Setter +public class CertifyRoomRequest { + private Long routineId; + private MultipartFile image; } diff --git a/src/main/java/com/moabam/api/dto/room/CertifyRoomsRequest.java b/src/main/java/com/moabam/api/dto/room/CertifyRoomsRequest.java index 6c6338e1..c2cf4110 100644 --- a/src/main/java/com/moabam/api/dto/room/CertifyRoomsRequest.java +++ b/src/main/java/com/moabam/api/dto/room/CertifyRoomsRequest.java @@ -2,11 +2,12 @@ import java.util.List; -import lombok.Builder; +import lombok.Getter; +import lombok.Setter; -@Builder -public record CertifyRoomsRequest( - List certifyRoomsRequest -) { +@Getter +@Setter +public class CertifyRoomsRequest { + private List certifyRoomsRequest; } diff --git a/src/main/java/com/moabam/global/error/model/ErrorMessage.java b/src/main/java/com/moabam/global/error/model/ErrorMessage.java index 8a16d99b..cd39ce68 100644 --- a/src/main/java/com/moabam/global/error/model/ErrorMessage.java +++ b/src/main/java/com/moabam/global/error/model/ErrorMessage.java @@ -31,6 +31,7 @@ public enum ErrorMessage { CERTIFICATION_NOT_FOUND("인증 정보가 없습니다."), NEED_TO_EXIT_ALL_ROOMS("모든 방에서 나가야 회원 탈퇴가 가능합니다."), PARTICIPANT_DEPORT_ERROR("방장은 자신을 추방할 수 없습니다."), + IMAGE_CONVERT_FAIL("이미지 변환을 실패했습니다."), LOGIN_FAILED("로그인에 실패했습니다."), REQUEST_FAILED("네트워크 접근 실패입니다."),