From 325dee19c79f9e0f22e553ef1d37631546ad2b01 Mon Sep 17 00:00:00 2001 From: Jimin0304 Date: Fri, 17 Nov 2023 21:30:46 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EA=B8=B0=ED=94=84=ED=8B=B0=EC=BD=98?= =?UTF-8?q?=20ResponseDTO=20=ED=98=95=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gifticon/dto/AddGifticonResponseDTO.java | 22 +++++++++++++++++++ .../gifticon/dto/GifticonResponseDTO.java | 3 --- .../gifticon/service/GifticonService.java | 7 +++--- 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/CSP2/switchcon/gifticon/dto/AddGifticonResponseDTO.java diff --git a/src/main/java/com/CSP2/switchcon/gifticon/dto/AddGifticonResponseDTO.java b/src/main/java/com/CSP2/switchcon/gifticon/dto/AddGifticonResponseDTO.java new file mode 100644 index 0000000..e4e72b1 --- /dev/null +++ b/src/main/java/com/CSP2/switchcon/gifticon/dto/AddGifticonResponseDTO.java @@ -0,0 +1,22 @@ +package com.CSP2.switchcon.gifticon.dto; + +import com.CSP2.switchcon.gifticon.domain.Gifticon; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import static lombok.AccessLevel.PRIVATE; + +@Getter +@AllArgsConstructor +@Builder(access = PRIVATE) +public class AddGifticonResponseDTO { + + private final long id; + + public static AddGifticonResponseDTO from (Gifticon gifticon) { + return AddGifticonResponseDTO.builder() + .id(gifticon.getId()) + .build(); + } +} diff --git a/src/main/java/com/CSP2/switchcon/gifticon/dto/GifticonResponseDTO.java b/src/main/java/com/CSP2/switchcon/gifticon/dto/GifticonResponseDTO.java index a8e2d5e..c31ffc4 100644 --- a/src/main/java/com/CSP2/switchcon/gifticon/dto/GifticonResponseDTO.java +++ b/src/main/java/com/CSP2/switchcon/gifticon/dto/GifticonResponseDTO.java @@ -17,8 +17,6 @@ @Builder(access = PRIVATE) public class GifticonResponseDTO { - private final long id; - private final String gifticonImg; private final String category; @@ -45,7 +43,6 @@ public class GifticonResponseDTO { public static GifticonResponseDTO from (Gifticon gifticon) { return GifticonResponseDTO.builder() - .id(gifticon.getId()) .gifticonImg(gifticon.getGifticonImg()) .category(gifticon.getCategory()) .store(gifticon.getStore()) diff --git a/src/main/java/com/CSP2/switchcon/gifticon/service/GifticonService.java b/src/main/java/com/CSP2/switchcon/gifticon/service/GifticonService.java index 1c7046c..f1e8a48 100644 --- a/src/main/java/com/CSP2/switchcon/gifticon/service/GifticonService.java +++ b/src/main/java/com/CSP2/switchcon/gifticon/service/GifticonService.java @@ -8,6 +8,7 @@ import com.CSP2.switchcon.gifticon.dto.GifticonRequestDTO; import com.CSP2.switchcon.gifticon.dto.GifticonResponseDTO; import com.CSP2.switchcon.gifticon.dto.OcrResponseDTO; +import com.CSP2.switchcon.gifticon.dto.AddGifticonResponseDTO; import com.CSP2.switchcon.gifticon.repository.GifticonRepository; import com.CSP2.switchcon.member.domain.Member; import jakarta.transaction.Transactional; @@ -15,14 +16,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; -import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; @Service @@ -81,7 +80,7 @@ public OcrResponseDTO getOcrData(String imgUrl) { } @Transactional - public GifticonResponseDTO addGifticon(Member member, GifticonRequestDTO requestDTO) { + public AddGifticonResponseDTO addGifticon(Member member, GifticonRequestDTO requestDTO) { Gifticon gifticon = Gifticon.builder() .gifticonImg(requestDTO.getGifticonImg()) @@ -98,7 +97,7 @@ public GifticonResponseDTO addGifticon(Member member, GifticonRequestDTO request .build(); Gifticon saved = gifticonRepository.save(gifticon); - return GifticonResponseDTO.from(saved); + return AddGifticonResponseDTO.from(saved); } @Transactional