diff --git a/server/src/main/java/server/haengdong/application/EventService.java b/server/src/main/java/server/haengdong/application/EventService.java index 73db3023b..2eb80f265 100644 --- a/server/src/main/java/server/haengdong/application/EventService.java +++ b/server/src/main/java/server/haengdong/application/EventService.java @@ -12,7 +12,6 @@ import server.haengdong.application.response.EventAppResponse; import server.haengdong.application.response.EventDetailAppResponse; import server.haengdong.application.response.EventImageAppResponse; -import server.haengdong.application.response.ImageNameAppResponse; import server.haengdong.application.response.MemberBillReportAppResponse; import server.haengdong.domain.bill.Bill; import server.haengdong.domain.bill.BillRepository; @@ -103,11 +102,11 @@ public void updateEvent(String token, EventUpdateAppRequest request) { } @Transactional - public void saveImages(String token, List imageNames) { + public void saveImages(String token, List imageNames) { Event event = getEvent(token); List images = imageNames.stream() - .map(imageNameAppResponse -> imageNameAppResponse.toEventImage(event)) + .map(imageName -> new EventImage(event, imageName)) .toList(); eventImageRepository.saveAll(images); @@ -118,10 +117,14 @@ public List findImages(String token) { return eventImageRepository.findAllByEvent(event) .stream() - .map(image -> new EventImageAppResponse(baseUrl + image.getName())) + .map(image -> new EventImageAppResponse(image.getId(), createUrl(image))) .toList(); } + private String createUrl(EventImage image) { + return baseUrl + image.getName(); + } + @Transactional public String deleteImage(String token, Long imageId) { EventImage eventImage = eventImageRepository.findById(imageId) diff --git a/server/src/main/java/server/haengdong/application/ImageService.java b/server/src/main/java/server/haengdong/application/ImageService.java index bae5d7612..6e0ffdb76 100644 --- a/server/src/main/java/server/haengdong/application/ImageService.java +++ b/server/src/main/java/server/haengdong/application/ImageService.java @@ -21,7 +21,7 @@ @Slf4j @RequiredArgsConstructor @Service -public class ImageUploadService { +public class ImageService { @Value("${image.bucket}") private String bucketName; @@ -31,16 +31,15 @@ public class ImageUploadService { private final S3Client s3Client; - public List uploadImages(List images) { + public List uploadImages(List images) { return images.stream() .map(this::uploadImage) .toList(); } - private ImageNameAppResponse uploadImage(MultipartFile image) { + private String uploadImage(MultipartFile image) { try (InputStream inputStream = image.getInputStream()) { - String fileName = uploadImageToStorage(inputStream, image); - return new ImageNameAppResponse(fileName); + return uploadImageToStorage(inputStream, image); } catch (IOException e) { throw new HaengdongException(HaengdongErrorCode.IMAGE_UPLOAD_FAIL); } @@ -61,4 +60,13 @@ private String uploadImageToStorage(InputStream inputStream, MultipartFile image s3Client.putObject(putObjectRequest, fromInputStream(inputStream, contentLength)); return imageName; } + + public void deleteImage(String imageName) { + DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder() + .bucket(bucketName) + .key(directoryPath + imageName) + .build(); + + s3Client.deleteObject(deleteObjectRequest); + } } diff --git a/server/src/main/java/server/haengdong/application/response/BillAppResponse.java b/server/src/main/java/server/haengdong/application/response/BillAppResponse.java index 8a5a5b2bc..6ee68935c 100644 --- a/server/src/main/java/server/haengdong/application/response/BillAppResponse.java +++ b/server/src/main/java/server/haengdong/application/response/BillAppResponse.java @@ -8,6 +8,7 @@ public record BillAppResponse( Long price, boolean isFixed ) { + public static BillAppResponse of(Bill bill) { return new BillAppResponse(bill.getId(), bill.getTitle(), bill.getPrice(), bill.isFixed()); } diff --git a/server/src/main/java/server/haengdong/application/response/EventImageAppResponse.java b/server/src/main/java/server/haengdong/application/response/EventImageAppResponse.java index 1528f876a..26e442403 100644 --- a/server/src/main/java/server/haengdong/application/response/EventImageAppResponse.java +++ b/server/src/main/java/server/haengdong/application/response/EventImageAppResponse.java @@ -1,6 +1,7 @@ package server.haengdong.application.response; public record EventImageAppResponse( + Long id, String url ) { } diff --git a/server/src/main/java/server/haengdong/application/response/MemberAppResponse.java b/server/src/main/java/server/haengdong/application/response/MemberAppResponse.java index b253ea697..98579b2d1 100644 --- a/server/src/main/java/server/haengdong/application/response/MemberAppResponse.java +++ b/server/src/main/java/server/haengdong/application/response/MemberAppResponse.java @@ -6,6 +6,7 @@ public record MemberAppResponse( Long id, String name ) { + public static MemberAppResponse of(Member member) { return new MemberAppResponse(member.getId(), member.getName()); } diff --git a/server/src/main/java/server/haengdong/application/response/MemberDepositAppResponse.java b/server/src/main/java/server/haengdong/application/response/MemberDepositAppResponse.java index 94dd77117..bb09e02df 100644 --- a/server/src/main/java/server/haengdong/application/response/MemberDepositAppResponse.java +++ b/server/src/main/java/server/haengdong/application/response/MemberDepositAppResponse.java @@ -7,6 +7,7 @@ public record MemberDepositAppResponse( String name, boolean isDeposited ) { + public static MemberDepositAppResponse of(Member member) { return new MemberDepositAppResponse(member.getId(), member.getName(), member.isDeposited()); } diff --git a/server/src/main/java/server/haengdong/application/response/MemberSaveAppResponse.java b/server/src/main/java/server/haengdong/application/response/MemberSaveAppResponse.java index 1d08536ba..bd1d117f2 100644 --- a/server/src/main/java/server/haengdong/application/response/MemberSaveAppResponse.java +++ b/server/src/main/java/server/haengdong/application/response/MemberSaveAppResponse.java @@ -6,6 +6,7 @@ public record MemberSaveAppResponse( Long id, String name ) { + public static MemberSaveAppResponse of(Member member) { return new MemberSaveAppResponse(member.getId(), member.getName()); } diff --git a/server/src/main/java/server/haengdong/application/response/MembersSaveAppResponse.java b/server/src/main/java/server/haengdong/application/response/MembersSaveAppResponse.java index e171f9950..c81fe0996 100644 --- a/server/src/main/java/server/haengdong/application/response/MembersSaveAppResponse.java +++ b/server/src/main/java/server/haengdong/application/response/MembersSaveAppResponse.java @@ -6,6 +6,7 @@ public record MembersSaveAppResponse( List members ) { + public static MembersSaveAppResponse of(List members) { return new MembersSaveAppResponse( members.stream() diff --git a/server/src/main/java/server/haengdong/application/response/StepAppResponse.java b/server/src/main/java/server/haengdong/application/response/StepAppResponse.java index 2537d1db1..57ca1860c 100644 --- a/server/src/main/java/server/haengdong/application/response/StepAppResponse.java +++ b/server/src/main/java/server/haengdong/application/response/StepAppResponse.java @@ -7,6 +7,7 @@ public record StepAppResponse( List bills, List members ) { + public static StepAppResponse of(Step step) { List billAppResponses = step.getBills().stream() .map(BillAppResponse::of) diff --git a/server/src/main/java/server/haengdong/exception/HaengdongErrorCode.java b/server/src/main/java/server/haengdong/exception/HaengdongErrorCode.java index 6884609ae..fc79123b9 100644 --- a/server/src/main/java/server/haengdong/exception/HaengdongErrorCode.java +++ b/server/src/main/java/server/haengdong/exception/HaengdongErrorCode.java @@ -30,6 +30,8 @@ public enum HaengdongErrorCode { DIFFERENT_STEP_MEMBERS("참여자 목록이 일치하지 않습니다."), + IMAGE_NOT_FOUND("존재하지 않는 이미지 입니다."), + /* Authentication */ PASSWORD_INVALID("비밀번호가 일치하지 않습니다."), diff --git a/server/src/main/java/server/haengdong/presentation/admin/AdminEventController.java b/server/src/main/java/server/haengdong/presentation/admin/AdminEventController.java index 976858427..8fd913dae 100644 --- a/server/src/main/java/server/haengdong/presentation/admin/AdminEventController.java +++ b/server/src/main/java/server/haengdong/presentation/admin/AdminEventController.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -13,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import server.haengdong.application.EventService; -import server.haengdong.application.ImageUploadService; +import server.haengdong.application.ImageService; import server.haengdong.application.response.ImageNameAppResponse; import server.haengdong.presentation.request.EventUpdateRequest; @@ -23,12 +24,13 @@ public class AdminEventController { private final EventService eventService; - private final ImageUploadService imageUploadService; + private final ImageService imageUploadService; @PostMapping("/api/admin/events/{eventId}/auth") public ResponseEntity authenticate() { return ResponseEntity.ok().build(); } + @PatchMapping("/api/admin/events/{eventId}") public ResponseEntity updateEvent( @PathVariable("eventId") String token, @@ -40,12 +42,14 @@ public ResponseEntity updateEvent( } @PostMapping("/api/admin/events/{eventId}/images") - public void uploadImages( + public ResponseEntity uploadImages( @PathVariable("eventId") String token, @RequestPart("images") List images ) { - List imageNames = imageUploadService.uploadImages(images); + List imageNames = imageUploadService.uploadImages(images); eventService.saveImages(token, imageNames); + + return ResponseEntity.ok().build(); } @DeleteMapping("/api/admin/events/{eventId}/images/{imageId}") diff --git a/server/src/main/java/server/haengdong/presentation/request/BillDetailUpdateRequest.java b/server/src/main/java/server/haengdong/presentation/request/BillDetailUpdateRequest.java index de670f28f..d0f69b148 100644 --- a/server/src/main/java/server/haengdong/presentation/request/BillDetailUpdateRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/BillDetailUpdateRequest.java @@ -13,6 +13,7 @@ public record BillDetailUpdateRequest( boolean isFixed ) { + public BillDetailUpdateAppRequest toAppRequest() { return new BillDetailUpdateAppRequest(this.id, this.price, this.isFixed); } diff --git a/server/src/main/java/server/haengdong/presentation/request/BillDetailsUpdateRequest.java b/server/src/main/java/server/haengdong/presentation/request/BillDetailsUpdateRequest.java index f09d101bd..091db5967 100644 --- a/server/src/main/java/server/haengdong/presentation/request/BillDetailsUpdateRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/BillDetailsUpdateRequest.java @@ -6,8 +6,12 @@ import server.haengdong.application.request.BillDetailsUpdateAppRequest; public record BillDetailsUpdateRequest( - @Valid @NotEmpty List billDetails + + @Valid + @NotEmpty + List billDetails ) { + public BillDetailsUpdateAppRequest toAppRequest() { return new BillDetailsUpdateAppRequest(billDetails.stream() .map(BillDetailUpdateRequest::toAppRequest) diff --git a/server/src/main/java/server/haengdong/presentation/request/BillUpdateRequest.java b/server/src/main/java/server/haengdong/presentation/request/BillUpdateRequest.java index a37c75013..d5ea67474 100644 --- a/server/src/main/java/server/haengdong/presentation/request/BillUpdateRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/BillUpdateRequest.java @@ -12,6 +12,7 @@ public record BillUpdateRequest( @NotNull(message = "지출 금액은 공백일 수 없습니다.") Long price ) { + public BillUpdateAppRequest toAppResponse() { return new BillUpdateAppRequest(title, price); } diff --git a/server/src/main/java/server/haengdong/presentation/request/EventLoginRequest.java b/server/src/main/java/server/haengdong/presentation/request/EventLoginRequest.java index a1286e903..d49a0e510 100644 --- a/server/src/main/java/server/haengdong/presentation/request/EventLoginRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/EventLoginRequest.java @@ -8,6 +8,7 @@ public record EventLoginRequest( @NotBlank(message = "비밀번호는 공백일 수 없습니다.") String password ) { + public EventLoginAppRequest toAppRequest(String token) { return new EventLoginAppRequest(token, password); } diff --git a/server/src/main/java/server/haengdong/presentation/request/MemberNameUpdateRequest.java b/server/src/main/java/server/haengdong/presentation/request/MemberNameUpdateRequest.java deleted file mode 100644 index fb1ff655f..000000000 --- a/server/src/main/java/server/haengdong/presentation/request/MemberNameUpdateRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package server.haengdong.presentation.request; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import server.haengdong.application.request.MemberNameUpdateAppRequest; - -public record MemberNameUpdateRequest( - - @NotNull(message = "멤버 id는 공백일 수 없습니다.") - Long id, - - @NotBlank(message = "멤버 이름은 공백일 수 없습니다.") - String name -) { - - public MemberNameUpdateAppRequest toAppRequest() { - return new MemberNameUpdateAppRequest(id, name); - } -} diff --git a/server/src/main/java/server/haengdong/presentation/request/MemberNamesUpdateRequest.java b/server/src/main/java/server/haengdong/presentation/request/MemberNamesUpdateRequest.java deleted file mode 100644 index 79c46590d..000000000 --- a/server/src/main/java/server/haengdong/presentation/request/MemberNamesUpdateRequest.java +++ /dev/null @@ -1,20 +0,0 @@ -package server.haengdong.presentation.request; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import java.util.List; -import server.haengdong.application.request.MemberNamesUpdateAppRequest; - -public record MemberNamesUpdateRequest( - @Valid - @NotEmpty - List members -) { - - public MemberNamesUpdateAppRequest toAppRequest() { - return new MemberNamesUpdateAppRequest(members.stream() - .map(MemberNameUpdateRequest::toAppRequest) - .toList() - ); - } -} diff --git a/server/src/main/java/server/haengdong/presentation/request/MembersSaveRequest.java b/server/src/main/java/server/haengdong/presentation/request/MembersSaveRequest.java index c5e2100fd..cc611742a 100644 --- a/server/src/main/java/server/haengdong/presentation/request/MembersSaveRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/MembersSaveRequest.java @@ -4,7 +4,10 @@ import server.haengdong.application.request.MemberSaveAppRequest; import server.haengdong.application.request.MembersSaveAppRequest; -public record MembersSaveRequest(List members) { +public record MembersSaveRequest( + List members +) { + public MembersSaveAppRequest toAppRequest() { return new MembersSaveAppRequest(members.stream() .map(member -> new MemberSaveAppRequest(member.name())) diff --git a/server/src/main/java/server/haengdong/presentation/response/BillResponse.java b/server/src/main/java/server/haengdong/presentation/response/BillResponse.java index 8b79896bb..0f3aaeaa0 100644 --- a/server/src/main/java/server/haengdong/presentation/response/BillResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/BillResponse.java @@ -8,6 +8,7 @@ public record BillResponse( Long price, boolean isFixed ) { + public static BillResponse of(BillAppResponse response) { return new BillResponse(response.id(), response.title(), response.price(), response.isFixed()); } diff --git a/server/src/main/java/server/haengdong/presentation/response/EventImageResponse.java b/server/src/main/java/server/haengdong/presentation/response/EventImageResponse.java new file mode 100644 index 000000000..da807655f --- /dev/null +++ b/server/src/main/java/server/haengdong/presentation/response/EventImageResponse.java @@ -0,0 +1,13 @@ +package server.haengdong.presentation.response; + +import server.haengdong.application.response.EventImageAppResponse; + +public record EventImageResponse( + Long id, + String url +) { + + public static EventImageResponse of(EventImageAppResponse response) { + return new EventImageResponse(response.id(), response.url()); + } +} diff --git a/server/src/main/java/server/haengdong/presentation/response/EventImagesResponse.java b/server/src/main/java/server/haengdong/presentation/response/EventImagesResponse.java index 2dd1530a6..d5c2b0ab8 100644 --- a/server/src/main/java/server/haengdong/presentation/response/EventImagesResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/EventImagesResponse.java @@ -3,12 +3,13 @@ import java.util.List; import server.haengdong.application.response.EventImageAppResponse; -public record EventImagesResponse(List urls) { - public static EventImagesResponse of(List images) { - List urls = images.stream() - .map(EventImageAppResponse::url) +public record EventImagesResponse(List images) { + + public static EventImagesResponse of(List responses) { + List images = responses.stream() + .map(EventImageResponse::of) .toList(); - return new EventImagesResponse(urls); + return new EventImagesResponse(images); } } diff --git a/server/src/main/java/server/haengdong/presentation/response/MemberSaveResponse.java b/server/src/main/java/server/haengdong/presentation/response/MemberSaveResponse.java index b0740c6ca..21a7e7969 100644 --- a/server/src/main/java/server/haengdong/presentation/response/MemberSaveResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/MemberSaveResponse.java @@ -6,6 +6,7 @@ public record MemberSaveResponse( Long id, String name ) { + public static MemberSaveResponse of(MemberSaveAppResponse response) { return new MemberSaveResponse(response.id(), response.name()); } diff --git a/server/src/main/java/server/haengdong/presentation/response/MembersSaveResponse.java b/server/src/main/java/server/haengdong/presentation/response/MembersSaveResponse.java index 04e9b133e..d4b7ad456 100644 --- a/server/src/main/java/server/haengdong/presentation/response/MembersSaveResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/MembersSaveResponse.java @@ -6,6 +6,7 @@ public record MembersSaveResponse( List members ) { + public static MembersSaveResponse of(MembersSaveAppResponse response) { return new MembersSaveResponse( response.members().stream() diff --git a/server/src/main/java/server/haengdong/presentation/response/StepResponse.java b/server/src/main/java/server/haengdong/presentation/response/StepResponse.java index 924651c73..a164e71f5 100644 --- a/server/src/main/java/server/haengdong/presentation/response/StepResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/StepResponse.java @@ -7,6 +7,7 @@ public record StepResponse( List bills, List members ) { + public static StepResponse of(StepAppResponse response) { List bills = response.bills().stream() .map(BillResponse::of) @@ -16,7 +17,6 @@ public static StepResponse of(StepAppResponse response) { .map(MemberResponse::of) .toList(); return new StepResponse(bills, members); - } } diff --git a/server/src/main/java/server/haengdong/presentation/response/StepsResponse.java b/server/src/main/java/server/haengdong/presentation/response/StepsResponse.java index baceeb549..8a66df1c6 100644 --- a/server/src/main/java/server/haengdong/presentation/response/StepsResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/StepsResponse.java @@ -6,6 +6,7 @@ public record StepsResponse( List steps ) { + public static StepsResponse of(List steps) { return new StepsResponse(steps.stream() .map(StepResponse::of) diff --git a/server/src/test/java/server/haengdong/application/EventServiceTest.java b/server/src/test/java/server/haengdong/application/EventServiceTest.java index a5aa3d456..bcfc0a3e4 100644 --- a/server/src/test/java/server/haengdong/application/EventServiceTest.java +++ b/server/src/test/java/server/haengdong/application/EventServiceTest.java @@ -201,12 +201,9 @@ void findAllImages() { void saveImages() { Event event = Fixture.EVENT1; eventRepository.save(event); - List imageNameAppResponses = List.of( - new ImageNameAppResponse("image1.jpg"), - new ImageNameAppResponse("image2.jpg") - ); + List imageNames = List.of("image1.jpg", "image2.jpg"); - eventService.saveImages(event.getToken(), imageNameAppResponses); + eventService.saveImages(event.getToken(), imageNames); List savedEventImages = eventImageRepository.findAllByEvent(event); assertThat(savedEventImages) @@ -217,4 +214,18 @@ void saveImages() { "image2.jpg" ); } + + @DisplayName("행사 이미지를 삭제한다.") + @Test + void deleteImage() { + Event event = Fixture.EVENT1; + eventRepository.save(event); + EventImage eventImage = new EventImage(event, "image1.jpg"); + eventImageRepository.save(eventImage); + + eventService.deleteImage(event.getToken(), eventImage.getId()); + + assertThat(eventImageRepository.findById(eventImage.getId())) + .isEmpty(); + } } diff --git a/server/src/test/java/server/haengdong/docs/AdminEventControllerDocsTest.java b/server/src/test/java/server/haengdong/docs/AdminEventControllerDocsTest.java index 066ed5f06..658c57512 100644 --- a/server/src/test/java/server/haengdong/docs/AdminEventControllerDocsTest.java +++ b/server/src/test/java/server/haengdong/docs/AdminEventControllerDocsTest.java @@ -7,6 +7,7 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.multipart; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; @@ -26,14 +27,14 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.restdocs.payload.JsonFieldType; import server.haengdong.application.EventService; -import server.haengdong.application.ImageUploadService; +import server.haengdong.application.ImageService; import server.haengdong.presentation.admin.AdminEventController; import server.haengdong.presentation.request.EventUpdateRequest; class AdminEventControllerDocsTest extends RestDocsSupport { private final EventService eventService = mock(EventService.class); - private final ImageUploadService imageUploadService = mock(ImageUploadService.class); + private final ImageService imageUploadService = mock(ImageService.class); @Override protected Object initController() { @@ -129,4 +130,28 @@ void uploadImages() throws Exception { ) ); } + + @DisplayName("행사 이미지를 삭제한다.") + @Test + void deleteImage() throws Exception { + String token = "TOKEN"; + + mockMvc.perform(delete("/api/admin/events/{eventId}/images/{imageId}", token, 1L) + .cookie(EVENT_COOKIE)) + .andDo(print()) + .andExpect(status().isOk()) + .andDo( + document("deleteImage", + preprocessRequest(prettyPrint()), + preprocessResponse(prettyPrint()), + pathParameters( + parameterWithName("eventId").description("행사 ID"), + parameterWithName("imageId").description("이미지 ID") + ), + requestCookies( + cookieWithName("eventToken").description("행사 관리자 토큰") + ) + ) + ); + } } diff --git a/server/src/test/java/server/haengdong/docs/EventControllerDocsTest.java b/server/src/test/java/server/haengdong/docs/EventControllerDocsTest.java index d0532fccb..0918721fd 100644 --- a/server/src/test/java/server/haengdong/docs/EventControllerDocsTest.java +++ b/server/src/test/java/server/haengdong/docs/EventControllerDocsTest.java @@ -200,9 +200,9 @@ void loginEvent() throws Exception { void findAllImages() throws Exception { String token = "TOKEN"; List imageNameAppResponses = List.of( - new EventImageAppResponse("https://host.com/image1.jpg"), - new EventImageAppResponse("https://host.com/image2.jpg"), - new EventImageAppResponse("https://host.com/zeze.jpg") + new EventImageAppResponse(1L, "https://host.com/image1.jpg"), + new EventImageAppResponse(2L, "https://host.com/image2.jpg"), + new EventImageAppResponse(3L, "https://host.com/zeze.jpg") ); given(eventService.findImages(token)).willReturn(imageNameAppResponses); @@ -217,8 +217,12 @@ void findAllImages() throws Exception { parameterWithName("eventId").description("행사 ID") ), responseFields( - fieldWithPath("urls").type(JsonFieldType.ARRAY) - .description("행사 이미지 목록") + fieldWithPath("images").type(JsonFieldType.ARRAY) + .description("행사 이미지 목록"), + fieldWithPath("images[].id").type(JsonFieldType.NUMBER) + .description("이미지 id"), + fieldWithPath("images[].url").type(JsonFieldType.STRING) + .description("이미지 url") ) ) ); diff --git a/server/src/test/java/server/haengdong/presentation/ControllerTestSupport.java b/server/src/test/java/server/haengdong/presentation/ControllerTestSupport.java index 76373f9f2..738823c40 100644 --- a/server/src/test/java/server/haengdong/presentation/ControllerTestSupport.java +++ b/server/src/test/java/server/haengdong/presentation/ControllerTestSupport.java @@ -11,7 +11,7 @@ import server.haengdong.application.AuthService; import server.haengdong.application.BillService; import server.haengdong.application.EventService; -import server.haengdong.application.ImageUploadService; +import server.haengdong.application.ImageService; import server.haengdong.application.MemberService; import server.haengdong.presentation.admin.AdminBillController; import server.haengdong.presentation.admin.AdminEventController; @@ -49,5 +49,5 @@ public abstract class ControllerTestSupport { protected BillService billService; @MockBean - protected ImageUploadService imageUploadService; + protected ImageService imageUploadService; } diff --git a/server/src/test/java/server/haengdong/presentation/EventControllerTest.java b/server/src/test/java/server/haengdong/presentation/EventControllerTest.java index dfdd969d3..90e7fd618 100644 --- a/server/src/test/java/server/haengdong/presentation/EventControllerTest.java +++ b/server/src/test/java/server/haengdong/presentation/EventControllerTest.java @@ -106,9 +106,9 @@ void loginEvent() throws Exception { void findAllImages() throws Exception { String token = "TOKEN"; List imageNameAppResponses = List.of( - new EventImageAppResponse("https://host.com/image1.jpg"), - new EventImageAppResponse("https://host.com/image2.jpg"), - new EventImageAppResponse("https://host.com/zeze.jpg") + new EventImageAppResponse(1L, "https://host.com/image1.jpg"), + new EventImageAppResponse(2L, "https://host.com/image2.jpg"), + new EventImageAppResponse(3L, "https://host.com/zeze.jpg") ); given(eventService.findImages(token)).willReturn(imageNameAppResponses);