Skip to content

Commit

Permalink
fix: record를 class로 바꾸고 바인딩 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
Shin-Jae-Yoon committed Nov 30, 2023
1 parent 80e7bcc commit 4f5abbc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
12 changes: 8 additions & 4 deletions src/main/java/com/moabam/api/application/image/ImageService.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -42,12 +45,13 @@ public List<String> uploadImages(List<? extends MultipartFile> multipartFiles, I
}

public List<NewImage> 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();
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/moabam/api/dto/room/CertifyRoomRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
11 changes: 6 additions & 5 deletions src/main/java/com/moabam/api/dto/room/CertifyRoomsRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import java.util.List;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

@Builder
public record CertifyRoomsRequest(
List<CertifyRoomRequest> certifyRoomsRequest
) {
@Getter
@Setter
public class CertifyRoomsRequest {

private List<CertifyRoomRequest> certifyRoomsRequest;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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("네트워크 접근 실패입니다."),
Expand Down

0 comments on commit 4f5abbc

Please sign in to comment.