From 7ec34682d1f8396b9d51bb2b44dbc5baf61dd927 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:05:26 +0900 Subject: [PATCH 01/11] =?UTF-8?q?remove:=20dto=20=EB=94=94=EB=A0=89?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduleImage/controller/ScheduleImageController.java | 4 ++-- .../dto/{ => request}/SaveScheduleImageRequest.java | 2 +- .../dto/{ => response}/SaveScheduleImageResponse.java | 4 ++-- .../scheduleImage/repository/ScheduleImageS3Repository.java | 2 +- .../domain/scheduleImage/service/SaveImageService.java | 4 ++-- .../domain/scheduleImage/service/ScheduleImageService.java | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) rename backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/{ => request}/SaveScheduleImageRequest.java (87%) rename backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/{ => response}/SaveScheduleImageResponse.java (87%) diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java index fb79ca5e..1c37e776 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java @@ -1,7 +1,7 @@ package com.isp.backend.domain.scheduleImage.controller; -import com.isp.backend.domain.scheduleImage.dto.SaveScheduleImageRequest; -import com.isp.backend.domain.scheduleImage.dto.SaveScheduleImageResponse; +import com.isp.backend.domain.scheduleImage.dto.request.SaveScheduleImageRequest; +import com.isp.backend.domain.scheduleImage.dto.response.SaveScheduleImageResponse; import com.isp.backend.domain.scheduleImage.service.SaveImageService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/SaveScheduleImageRequest.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java similarity index 87% rename from backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/SaveScheduleImageRequest.java rename to backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java index 852acc87..ad12cafa 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/SaveScheduleImageRequest.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java @@ -1,4 +1,4 @@ -package com.isp.backend.domain.scheduleImage.dto; +package com.isp.backend.domain.scheduleImage.dto.request; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Getter; diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/SaveScheduleImageResponse.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/SaveScheduleImageResponse.java similarity index 87% rename from backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/SaveScheduleImageResponse.java rename to backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/SaveScheduleImageResponse.java index d6270049..cd38d604 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/SaveScheduleImageResponse.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/SaveScheduleImageResponse.java @@ -1,4 +1,4 @@ -package com.isp.backend.domain.scheduleImage.dto; +package com.isp.backend.domain.scheduleImage.dto.response; import com.isp.backend.domain.scheduleImage.entity.ScheduleImage; import lombok.Getter; @@ -14,4 +14,4 @@ public SaveScheduleImageResponse(ScheduleImage scheduleImage) { this.scheduleId = scheduleImage.getSchedule().getId(); this.path = scheduleImage.getPath(); } -} +} \ No newline at end of file diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/repository/ScheduleImageS3Repository.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/repository/ScheduleImageS3Repository.java index 991f460f..2dbf3660 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/repository/ScheduleImageS3Repository.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/repository/ScheduleImageS3Repository.java @@ -1,6 +1,6 @@ package com.isp.backend.domain.scheduleImage.repository; -import com.isp.backend.domain.scheduleImage.dto.SaveScheduleImageRequest; +import com.isp.backend.domain.scheduleImage.dto.request.SaveScheduleImageRequest; import io.awspring.cloud.s3.S3Resource; import io.awspring.cloud.s3.S3Template; import lombok.AccessLevel; diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveImageService.java index 17f55751..95102437 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveImageService.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveImageService.java @@ -1,7 +1,7 @@ package com.isp.backend.domain.scheduleImage.service; -import com.isp.backend.domain.scheduleImage.dto.SaveScheduleImageRequest; -import com.isp.backend.domain.scheduleImage.dto.SaveScheduleImageResponse; +import com.isp.backend.domain.scheduleImage.dto.request.SaveScheduleImageRequest; +import com.isp.backend.domain.scheduleImage.dto.response.SaveScheduleImageResponse; import org.springframework.web.multipart.MultipartFile; public interface SaveImageService { diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java index 989eef97..9be23f52 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java @@ -2,8 +2,8 @@ import com.isp.backend.domain.schedule.entity.Schedule; import com.isp.backend.domain.schedule.repository.ScheduleRepository; -import com.isp.backend.domain.scheduleImage.dto.SaveScheduleImageRequest; -import com.isp.backend.domain.scheduleImage.dto.SaveScheduleImageResponse; +import com.isp.backend.domain.scheduleImage.dto.request.SaveScheduleImageRequest; +import com.isp.backend.domain.scheduleImage.dto.response.SaveScheduleImageResponse; import com.isp.backend.domain.scheduleImage.entity.ScheduleImage; import com.isp.backend.domain.scheduleImage.repository.ScheduleImageRepository; import com.isp.backend.domain.scheduleImage.repository.ScheduleImageS3Repository; From d910830d17fe6bbba779ab558681a27ce81a54b6 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:06:23 +0900 Subject: [PATCH 02/11] =?UTF-8?q?fix:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduleImage/dto/request/SaveScheduleImageRequest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java index ad12cafa..177c699a 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java @@ -13,7 +13,4 @@ public class SaveScheduleImageRequest { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime saveDate; -// public Long scheduleId() { -// return scheduleId; -// } } \ No newline at end of file From 3a0c62986f4121564fd1a5f48f1847754758bd83 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:07:08 +0900 Subject: [PATCH 03/11] =?UTF-8?q?feat:=20@CreateDate=EB=A5=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EC=97=AC=20=EC=82=AC=EC=A7=84=20persist=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=EB=8F=84=20=ED=95=A8=EA=BB=98=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=20c69f2f?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/SaveScheduleImageRequest.java | 6 ------ .../dto/response/SaveScheduleImageResponse.java | 2 ++ .../domain/scheduleImage/entity/ScheduleImage.java | 12 ++++++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java index 177c699a..7fbb33fb 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/request/SaveScheduleImageRequest.java @@ -1,16 +1,10 @@ package com.isp.backend.domain.scheduleImage.dto.request; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor public class SaveScheduleImageRequest { private Long scheduleId; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime saveDate; - } \ No newline at end of file diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/SaveScheduleImageResponse.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/SaveScheduleImageResponse.java index cd38d604..8a2427c8 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/SaveScheduleImageResponse.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/SaveScheduleImageResponse.java @@ -8,10 +8,12 @@ public class SaveScheduleImageResponse { private Long id; private Long scheduleId; private String path; + private String saveDate; public SaveScheduleImageResponse(ScheduleImage scheduleImage) { this.id = scheduleImage.getId(); this.scheduleId = scheduleImage.getSchedule().getId(); this.path = scheduleImage.getPath(); + this.saveDate = scheduleImage.getSaveDate(); } } \ No newline at end of file diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/entity/ScheduleImage.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/entity/ScheduleImage.java index 49264ecc..19864d53 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/entity/ScheduleImage.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/entity/ScheduleImage.java @@ -4,6 +4,10 @@ import jakarta.persistence.*; import lombok.Getter; import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; @Entity @Getter @@ -20,8 +24,16 @@ public class ScheduleImage { private Schedule schedule; private String path; + @CreatedDate + private String saveDate; + public ScheduleImage(Schedule schedule, String path) { this.schedule = schedule; this.path = path; } + + @PrePersist + public void onPrePersist(){ + this.saveDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + } } \ No newline at end of file From cd9d4a7385a7f3d3b23a9b22c2cd3ca5600666e0 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:08:32 +0900 Subject: [PATCH 04/11] =?UTF-8?q?feat:=20=ED=8A=B9=EC=A0=95=20=EC=9D=BC?= =?UTF-8?q?=EC=A0=95=EC=9D=98=20=EB=AA=A8=EB=93=A0=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20api?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleImageController.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java index 1c37e776..5346a7b5 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java @@ -2,7 +2,7 @@ import com.isp.backend.domain.scheduleImage.dto.request.SaveScheduleImageRequest; import com.isp.backend.domain.scheduleImage.dto.response.SaveScheduleImageResponse; -import com.isp.backend.domain.scheduleImage.service.SaveImageService; +import com.isp.backend.domain.scheduleImage.service.SaveScheduleImageService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -13,12 +13,19 @@ @RequestMapping("/scheduleImages") public class ScheduleImageController { - private final SaveImageService saveImageService; + private final SaveScheduleImageService saveScheduleImageService; + private final ReadScheduleImageService readScheduleImageService; @PostMapping @ResponseStatus(HttpStatus.CREATED) public SaveScheduleImageResponse create(@RequestPart(value = "image", required = false) MultipartFile image, - @RequestPart(value = "saveScheduleImageRequest") SaveScheduleImageRequest request) { - return saveImageService.save(request, image); + @RequestPart(value = "saveScheduleImageRequest") SaveScheduleImageRequest request) { + return saveScheduleImageService.save(request, image); + } + + @GetMapping("/{scheduleId}") + @ResponseStatus(HttpStatus.CREATED) + public ReadScheduleImageResponse read(@PathVariable(name = "scheduleId") Long scheduleId) { + return readScheduleImageService.read(scheduleId); } } \ No newline at end of file From 4998b7937d3f61c893dc09d13b328144895c8212 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:09:06 +0900 Subject: [PATCH 05/11] =?UTF-8?q?feat:=20=ED=8A=B9=EC=A0=95=20=EC=9D=BC?= =?UTF-8?q?=EC=A0=95=EC=9D=98=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20dto=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/ReadScheduleImageResponse.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/ReadScheduleImageResponse.java diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/ReadScheduleImageResponse.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/ReadScheduleImageResponse.java new file mode 100644 index 00000000..7feb915b --- /dev/null +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/dto/response/ReadScheduleImageResponse.java @@ -0,0 +1,13 @@ +package com.isp.backend.domain.scheduleImage.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Map; + +@Getter +@AllArgsConstructor +public class ReadScheduleImageResponse { + private Long scheduleId; + private Map pathAndSaveDate; +} \ No newline at end of file From 1fd44b51cfdb850b7104ff1e0011b0e766d0320d Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:09:16 +0900 Subject: [PATCH 06/11] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EC=A0=80=EC=9E=A5=20=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{SaveImageService.java => SaveScheduleImageService.java} | 2 +- .../domain/scheduleImage/service/ScheduleImageService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename backend/src/main/java/com/isp/backend/domain/scheduleImage/service/{SaveImageService.java => SaveScheduleImageService.java} (89%) diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveScheduleImageService.java similarity index 89% rename from backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveImageService.java rename to backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveScheduleImageService.java index 95102437..eec4d95f 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveImageService.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/SaveScheduleImageService.java @@ -4,7 +4,7 @@ import com.isp.backend.domain.scheduleImage.dto.response.SaveScheduleImageResponse; import org.springframework.web.multipart.MultipartFile; -public interface SaveImageService { +public interface SaveScheduleImageService { SaveScheduleImageResponse save(SaveScheduleImageRequest request, MultipartFile image); } \ No newline at end of file diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java index 9be23f52..eeb8fe26 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java @@ -13,7 +13,7 @@ @Service @RequiredArgsConstructor -public class ScheduleImageService implements SaveImageService { +public class ScheduleImageService implements SaveScheduleImageService { private final ScheduleImageS3Repository scheduleImageS3Repository; private final ScheduleRepository scheduleRepository; From fb4fd40a6f8271acdca5a3ebf4ba1ac9e2f53af5 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:10:09 +0900 Subject: [PATCH 07/11] =?UTF-8?q?feat:=20path=EC=99=80=20saveDate=EB=A5=BC?= =?UTF-8?q?=20map=EC=9C=BC=EB=A1=9C=20=EB=AC=B6=EC=96=B4=EC=84=9C=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ScheduleImageRepository.java | 3 +++ .../service/ReadScheduleImageService.java | 7 +++++++ .../service/ScheduleImageService.java | 19 ++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ReadScheduleImageService.java diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/repository/ScheduleImageRepository.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/repository/ScheduleImageRepository.java index bc05c3e5..a5b079f8 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/repository/ScheduleImageRepository.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/repository/ScheduleImageRepository.java @@ -3,5 +3,8 @@ import com.isp.backend.domain.scheduleImage.entity.ScheduleImage; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + public interface ScheduleImageRepository extends JpaRepository { + List findByScheduleId(Long scheduleId); } \ No newline at end of file diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ReadScheduleImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ReadScheduleImageService.java new file mode 100644 index 00000000..e6c153f7 --- /dev/null +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ReadScheduleImageService.java @@ -0,0 +1,7 @@ +package com.isp.backend.domain.scheduleImage.service; + +import com.isp.backend.domain.scheduleImage.dto.response.ReadScheduleImageResponse; + +public interface ReadScheduleImageService { + ReadScheduleImageResponse read(Long scheduleId); +} \ No newline at end of file diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java index eeb8fe26..075e2b8c 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java @@ -3,6 +3,7 @@ import com.isp.backend.domain.schedule.entity.Schedule; import com.isp.backend.domain.schedule.repository.ScheduleRepository; import com.isp.backend.domain.scheduleImage.dto.request.SaveScheduleImageRequest; +import com.isp.backend.domain.scheduleImage.dto.response.ReadScheduleImageResponse; import com.isp.backend.domain.scheduleImage.dto.response.SaveScheduleImageResponse; import com.isp.backend.domain.scheduleImage.entity.ScheduleImage; import com.isp.backend.domain.scheduleImage.repository.ScheduleImageRepository; @@ -11,9 +12,13 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + @Service @RequiredArgsConstructor -public class ScheduleImageService implements SaveScheduleImageService { +public class ScheduleImageService implements SaveScheduleImageService, ReadScheduleImageService { private final ScheduleImageS3Repository scheduleImageS3Repository; private final ScheduleRepository scheduleRepository; @@ -28,4 +33,16 @@ public SaveScheduleImageResponse save(SaveScheduleImageRequest request, Multipar scheduleImageRepository.save(scheduleImage); return new SaveScheduleImageResponse(scheduleImage); } + + @Override + public ReadScheduleImageResponse read(Long scheduleId) { + List scheduleImages = scheduleImageRepository.findByScheduleId(scheduleId); + Map pathSaveDateMap = new HashMap<>(); + + scheduleImages.forEach(scheduleImage -> + pathSaveDateMap.put(scheduleImage.getSaveDate(), scheduleImage.getPath()) + ); + + return new ReadScheduleImageResponse(scheduleId, pathSaveDateMap); + } } \ No newline at end of file From b33cb2e75981f374f897824af9927aa34670fe03 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:10:50 +0900 Subject: [PATCH 08/11] =?UTF-8?q?fix:=20=EC=A0=81=EC=A0=88=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=80=20201=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=EB=A5=BC=20200=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduleImage/controller/ScheduleImageController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java index 5346a7b5..4c4aad21 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java @@ -1,7 +1,9 @@ package com.isp.backend.domain.scheduleImage.controller; import com.isp.backend.domain.scheduleImage.dto.request.SaveScheduleImageRequest; +import com.isp.backend.domain.scheduleImage.dto.response.ReadScheduleImageResponse; import com.isp.backend.domain.scheduleImage.dto.response.SaveScheduleImageResponse; +import com.isp.backend.domain.scheduleImage.service.ReadScheduleImageService; import com.isp.backend.domain.scheduleImage.service.SaveScheduleImageService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -24,7 +26,7 @@ public SaveScheduleImageResponse create(@RequestPart(value = "image", required = } @GetMapping("/{scheduleId}") - @ResponseStatus(HttpStatus.CREATED) + @ResponseStatus(HttpStatus.OK) public ReadScheduleImageResponse read(@PathVariable(name = "scheduleId") Long scheduleId) { return readScheduleImageService.read(scheduleId); } From 5d2f5a4dec062fc174cca17e3fd4607a4faf9b39 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:11:10 +0900 Subject: [PATCH 09/11] =?UTF-8?q?feat:=20ScheduleImageId=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=9B=EC=95=84=20=ED=8A=B9=EC=A0=95=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20del?= =?UTF-8?q?ete=20api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleImageController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java index 4c4aad21..bf23d5c4 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java @@ -7,9 +7,13 @@ import com.isp.backend.domain.scheduleImage.service.SaveScheduleImageService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +@RestController +@RequiredArgsConstructor +@RequestMapping("/scheduleImages") @RestController @RequiredArgsConstructor @RequestMapping("/scheduleImages") @@ -17,6 +21,7 @@ public class ScheduleImageController { private final SaveScheduleImageService saveScheduleImageService; private final ReadScheduleImageService readScheduleImageService; + private final DeleteScheduleImageService deleteScheduleImageService; @PostMapping @ResponseStatus(HttpStatus.CREATED) @@ -30,4 +35,11 @@ public SaveScheduleImageResponse create(@RequestPart(value = "image", required = public ReadScheduleImageResponse read(@PathVariable(name = "scheduleId") Long scheduleId) { return readScheduleImageService.read(scheduleId); } + + @DeleteMapping("/{scheduleImageId}") + @ResponseStatus(HttpStatus.OK) + public ResponseEntity delete(@PathVariable(name = "scheduleImageId") Long scheduleImageId) { + return deleteScheduleImageService.delete(scheduleImageId); + } + } \ No newline at end of file From 9af73ffe88823c8bcf24ed34ca1f8fca51fe7f70 Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:24:40 +0900 Subject: [PATCH 10/11] =?UTF-8?q?delete:=20=EC=A4=91=EB=B3=B5=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=EB=90=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduleImage/controller/ScheduleImageController.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java index bf23d5c4..ca20b740 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/controller/ScheduleImageController.java @@ -3,6 +3,7 @@ import com.isp.backend.domain.scheduleImage.dto.request.SaveScheduleImageRequest; import com.isp.backend.domain.scheduleImage.dto.response.ReadScheduleImageResponse; import com.isp.backend.domain.scheduleImage.dto.response.SaveScheduleImageResponse; +import com.isp.backend.domain.scheduleImage.service.DeleteScheduleImageService; import com.isp.backend.domain.scheduleImage.service.ReadScheduleImageService; import com.isp.backend.domain.scheduleImage.service.SaveScheduleImageService; import lombok.RequiredArgsConstructor; @@ -11,9 +12,6 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -@RestController -@RequiredArgsConstructor -@RequestMapping("/scheduleImages") @RestController @RequiredArgsConstructor @RequestMapping("/scheduleImages") From 51fdb18e9ebfeef80732dc9314eb42295113b9ca Mon Sep 17 00:00:00 2001 From: Kim Jiyoon Date: Sat, 10 Aug 2024 20:25:00 +0900 Subject: [PATCH 11/11] =?UTF-8?q?feat:=20=ED=8A=B9=EC=A0=95=20=EC=9D=BC?= =?UTF-8?q?=EC=A0=95=EC=9D=98=20=ED=8A=B9=EC=A0=95=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DeleteScheduleImageService.java | 7 +++++++ .../service/ScheduleImageService.java | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 backend/src/main/java/com/isp/backend/domain/scheduleImage/service/DeleteScheduleImageService.java diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/DeleteScheduleImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/DeleteScheduleImageService.java new file mode 100644 index 00000000..d51d5e01 --- /dev/null +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/DeleteScheduleImageService.java @@ -0,0 +1,7 @@ +package com.isp.backend.domain.scheduleImage.service; + +import org.springframework.http.ResponseEntity; + +public interface DeleteScheduleImageService { + ResponseEntity delete(Long scheduleImageId); +} \ No newline at end of file diff --git a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java index 075e2b8c..ad83f983 100644 --- a/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java +++ b/backend/src/main/java/com/isp/backend/domain/scheduleImage/service/ScheduleImageService.java @@ -9,6 +9,8 @@ import com.isp.backend.domain.scheduleImage.repository.ScheduleImageRepository; import com.isp.backend.domain.scheduleImage.repository.ScheduleImageS3Repository; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -18,7 +20,7 @@ @Service @RequiredArgsConstructor -public class ScheduleImageService implements SaveScheduleImageService, ReadScheduleImageService { +public class ScheduleImageService implements SaveScheduleImageService, ReadScheduleImageService, DeleteScheduleImageService { private final ScheduleImageS3Repository scheduleImageS3Repository; private final ScheduleRepository scheduleRepository; @@ -45,4 +47,14 @@ public ReadScheduleImageResponse read(Long scheduleId) { return new ReadScheduleImageResponse(scheduleId, pathSaveDateMap); } + + @Override + public ResponseEntity delete(Long scheduleImageId) { + if (!scheduleImageRepository.existsById(scheduleImageId)) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); + } + + scheduleImageRepository.deleteById(scheduleImageId); + return ResponseEntity.noContent().build(); + } } \ No newline at end of file