Skip to content

Commit

Permalink
chore: 기프티콘 ResponseDTO 형식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimin0304 committed Nov 17, 2023
1 parent 53c2ef7 commit 325dee1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
@Builder(access = PRIVATE)
public class GifticonResponseDTO {

private final long id;

private final String gifticonImg;

private final String category;
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
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;
import lombok.RequiredArgsConstructor;
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
Expand Down Expand Up @@ -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())
Expand All @@ -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
Expand Down

0 comments on commit 325dee1

Please sign in to comment.