Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: record를 class로 바꿔서 바인딩 해결 #195

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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