From 6232783c191b2a9d18e155d1dafd8541b22b32f3 Mon Sep 17 00:00:00 2001 From: JaeUk Date: Thu, 9 May 2024 20:10:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20#110=20=EC=95=85=EA=B8=B0=20=EB=A7=A4?= =?UTF-8?q?=EB=AC=BC=20=EB=8B=A8=EA=B1=B4=20=EC=A1=B0=ED=9A=8C=20API=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EC=97=90=20?= =?UTF-8?q?=ED=8C=90=EB=A7=A4=EC=9E=90=20=EC=A0=95=EB=B3=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AcousticAndClassicGuitarResponse.java | 4 +-- .../dto/response/AmplifierResponse.java | 4 +-- .../dto/response/AudioEquipmentResponse.java | 4 +-- .../dto/response/BassGuitarResponse.java | 4 +-- .../dto/response/InstrumentResponse.java | 34 ++++++++++++++----- .../dto/response/EffectorResponse.java | 4 +-- .../dto/response/ElectricGuitarResponse.java | 4 +-- .../controller/InstrumentControllerTest.java | 14 ++++---- 8 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/ajou/hertz/domain/instrument/acoustic_and_classic_guitar/dto/response/AcousticAndClassicGuitarResponse.java b/src/main/java/com/ajou/hertz/domain/instrument/acoustic_and_classic_guitar/dto/response/AcousticAndClassicGuitarResponse.java index 8248462..2ccec2c 100644 --- a/src/main/java/com/ajou/hertz/domain/instrument/acoustic_and_classic_guitar/dto/response/AcousticAndClassicGuitarResponse.java +++ b/src/main/java/com/ajou/hertz/domain/instrument/acoustic_and_classic_guitar/dto/response/AcousticAndClassicGuitarResponse.java @@ -36,7 +36,7 @@ public class AcousticAndClassicGuitarResponse extends InstrumentResponse { private AcousticAndClassicGuitarResponse( Long id, - Long sellerId, + SellerResponse seller, String title, InstrumentProgressStatus progressStatus, AddressResponse tradeAddress, @@ -52,7 +52,7 @@ private AcousticAndClassicGuitarResponse( AcousticAndClassicGuitarPickUp pickUp ) { super( - id, sellerId, InstrumentCategory.ACOUSTIC_AND_CLASSIC_GUITAR, title, progressStatus, tradeAddress, + id, seller, InstrumentCategory.ACOUSTIC_AND_CLASSIC_GUITAR, title, progressStatus, tradeAddress, qualityStatus, price, hasAnomaly, description, images, hashtags ); this.brand = brand; diff --git a/src/main/java/com/ajou/hertz/domain/instrument/amplifier/dto/response/AmplifierResponse.java b/src/main/java/com/ajou/hertz/domain/instrument/amplifier/dto/response/AmplifierResponse.java index ec3d6f0..21aebbb 100644 --- a/src/main/java/com/ajou/hertz/domain/instrument/amplifier/dto/response/AmplifierResponse.java +++ b/src/main/java/com/ajou/hertz/domain/instrument/amplifier/dto/response/AmplifierResponse.java @@ -32,7 +32,7 @@ public class AmplifierResponse extends InstrumentResponse { private AmplifierResponse( Long id, - Long sellerId, + SellerResponse seller, String title, InstrumentProgressStatus progressStatus, AddressResponse tradeAddress, @@ -47,7 +47,7 @@ private AmplifierResponse( AmplifierUsage usage ) { super( - id, sellerId, InstrumentCategory.AMPLIFIER, title, progressStatus, tradeAddress, + id, seller, InstrumentCategory.AMPLIFIER, title, progressStatus, tradeAddress, qualityStatus, price, hasAnomaly, description, images, hashtags ); this.type = type; diff --git a/src/main/java/com/ajou/hertz/domain/instrument/audio_equipment/dto/response/AudioEquipmentResponse.java b/src/main/java/com/ajou/hertz/domain/instrument/audio_equipment/dto/response/AudioEquipmentResponse.java index b98f7f6..86750d0 100644 --- a/src/main/java/com/ajou/hertz/domain/instrument/audio_equipment/dto/response/AudioEquipmentResponse.java +++ b/src/main/java/com/ajou/hertz/domain/instrument/audio_equipment/dto/response/AudioEquipmentResponse.java @@ -24,7 +24,7 @@ public class AudioEquipmentResponse extends InstrumentResponse { private AudioEquipmentResponse( Long id, - Long sellerId, + SellerResponse seller, String title, InstrumentProgressStatus progressStatus, AddressResponse tradeAddress, @@ -37,7 +37,7 @@ private AudioEquipmentResponse( AudioEquipmentType type ) { super( - id, sellerId, InstrumentCategory.AUDIO_EQUIPMENT, title, progressStatus, tradeAddress, + id, seller, InstrumentCategory.AUDIO_EQUIPMENT, title, progressStatus, tradeAddress, qualityStatus, price, hasAnomaly, description, images, hashtags ); this.type = type; diff --git a/src/main/java/com/ajou/hertz/domain/instrument/bass_guitar/dto/response/BassGuitarResponse.java b/src/main/java/com/ajou/hertz/domain/instrument/bass_guitar/dto/response/BassGuitarResponse.java index 430ebf0..e3e2c73 100644 --- a/src/main/java/com/ajou/hertz/domain/instrument/bass_guitar/dto/response/BassGuitarResponse.java +++ b/src/main/java/com/ajou/hertz/domain/instrument/bass_guitar/dto/response/BassGuitarResponse.java @@ -36,7 +36,7 @@ public class BassGuitarResponse extends InstrumentResponse { private BassGuitarResponse( Long id, - Long sellerId, + SellerResponse seller, String title, InstrumentProgressStatus progressStatus, AddressResponse tradeAddress, @@ -52,7 +52,7 @@ private BassGuitarResponse( GuitarColor color ) { super( - id, sellerId, InstrumentCategory.BASS_GUITAR, title, progressStatus, tradeAddress, + id, seller, InstrumentCategory.BASS_GUITAR, title, progressStatus, tradeAddress, qualityStatus, price, hasAnomaly, description, images, hashtags ); this.brand = brand; diff --git a/src/main/java/com/ajou/hertz/domain/instrument/dto/response/InstrumentResponse.java b/src/main/java/com/ajou/hertz/domain/instrument/dto/response/InstrumentResponse.java index b0d81b7..acaeccd 100644 --- a/src/main/java/com/ajou/hertz/domain/instrument/dto/response/InstrumentResponse.java +++ b/src/main/java/com/ajou/hertz/domain/instrument/dto/response/InstrumentResponse.java @@ -1,18 +1,18 @@ package com.ajou.hertz.domain.instrument.dto.response; -import java.util.List; - import com.ajou.hertz.common.dto.response.AddressResponse; import com.ajou.hertz.domain.instrument.constant.InstrumentCategory; import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus; import com.ajou.hertz.domain.instrument.dto.InstrumentDto; - +import com.ajou.hertz.domain.user.dto.UserDto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @AllArgsConstructor(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter @@ -21,8 +21,8 @@ public abstract class InstrumentResponse { @Schema(description = "Id of instrument", example = "2") private Long id; - @Schema(description = "Id of seller", example = "1") - private Long sellerId; + @Schema(description = "판매자 정보") + private SellerResponse seller; @Schema(description = "종류") private InstrumentCategory category; @@ -56,7 +56,7 @@ public abstract class InstrumentResponse { protected InstrumentResponse(InstrumentDto instrumentDto) { this.id = instrumentDto.getId(); - this.sellerId = instrumentDto.getSeller().getId(); + this.seller = SellerResponse.from(instrumentDto.getSeller()); this.category = instrumentDto.getCategory(); this.title = instrumentDto.getTitle(); this.progressStatus = instrumentDto.getProgressStatus(); @@ -66,8 +66,26 @@ protected InstrumentResponse(InstrumentDto instrumentDto) { this.hasAnomaly = instrumentDto.getHasAnomaly(); this.description = instrumentDto.getDescription(); this.images = instrumentDto.getImages().stream() - .map(InstrumentImageResponse::from) - .toList(); + .map(InstrumentImageResponse::from) + .toList(); this.hashtags = instrumentDto.getHashtags(); } + + public record SellerResponse( + @Schema( + description = "Id of user", + example = "1" + ) Long id, + @Schema( + description = "연락 수단", + example = "https://contack-link" + ) String contactLink + ) { + private static SellerResponse from(UserDto userDto) { + return new SellerResponse( + userDto.getId(), + userDto.getContactLink() + ); + } + } } diff --git a/src/main/java/com/ajou/hertz/domain/instrument/effector/dto/response/EffectorResponse.java b/src/main/java/com/ajou/hertz/domain/instrument/effector/dto/response/EffectorResponse.java index 42f57c5..ec74535 100644 --- a/src/main/java/com/ajou/hertz/domain/instrument/effector/dto/response/EffectorResponse.java +++ b/src/main/java/com/ajou/hertz/domain/instrument/effector/dto/response/EffectorResponse.java @@ -28,7 +28,7 @@ public class EffectorResponse extends InstrumentResponse { private EffectorResponse( Long id, - Long sellerId, + SellerResponse seller, String title, InstrumentProgressStatus progressStatus, AddressResponse tradeAddress, @@ -42,7 +42,7 @@ private EffectorResponse( EffectorFeature feature ) { super( - id, sellerId, InstrumentCategory.EFFECTOR, title, progressStatus, tradeAddress, + id, seller, InstrumentCategory.EFFECTOR, title, progressStatus, tradeAddress, qualityStatus, price, hasAnomaly, description, images, hashtags ); this.type = type; diff --git a/src/main/java/com/ajou/hertz/domain/instrument/electric_guitar/dto/response/ElectricGuitarResponse.java b/src/main/java/com/ajou/hertz/domain/instrument/electric_guitar/dto/response/ElectricGuitarResponse.java index 0d55d0e..8d84db9 100644 --- a/src/main/java/com/ajou/hertz/domain/instrument/electric_guitar/dto/response/ElectricGuitarResponse.java +++ b/src/main/java/com/ajou/hertz/domain/instrument/electric_guitar/dto/response/ElectricGuitarResponse.java @@ -35,7 +35,7 @@ public class ElectricGuitarResponse extends InstrumentResponse { private ElectricGuitarResponse( Long id, - Long sellerId, + SellerResponse seller, String title, InstrumentProgressStatus progressStatus, AddressResponse tradeAddress, @@ -51,7 +51,7 @@ private ElectricGuitarResponse( GuitarColor color ) { super( - id, sellerId, InstrumentCategory.ELECTRIC_GUITAR, title, progressStatus, tradeAddress, + id, seller, InstrumentCategory.ELECTRIC_GUITAR, title, progressStatus, tradeAddress, qualityStatus, price, hasAnomaly, description, images, hashtags ); this.brand = brand; diff --git a/src/test/java/com/ajou/hertz/unit/domain/instrument/controller/InstrumentControllerTest.java b/src/test/java/com/ajou/hertz/unit/domain/instrument/controller/InstrumentControllerTest.java index dfaf5ab..a131789 100644 --- a/src/test/java/com/ajou/hertz/unit/domain/instrument/controller/InstrumentControllerTest.java +++ b/src/test/java/com/ajou/hertz/unit/domain/instrument/controller/InstrumentControllerTest.java @@ -110,7 +110,7 @@ public InstrumentControllerTest(MockMvc mvc) { ) .andExpect(status().isOk()) .andExpect(jsonPath("$.id").value(expectedResult.getId())) - .andExpect(jsonPath("$.sellerId").value(expectedResult.getSeller().getId())) + .andExpect(jsonPath("$.seller.id").value(expectedResult.getSeller().getId())) .andExpect(jsonPath("$.category").value(expectedResult.getCategory().name())); then(instrumentQueryService).should().getInstrumentDtoById(instrumentId); verifyEveryMocksShouldHaveNoMoreInteractions(); @@ -433,7 +433,7 @@ public InstrumentControllerTest(MockMvc mvc) { ) .andExpect(status().isCreated()) .andExpect(jsonPath("$.id").value(expectedResult.getId())) - .andExpect(jsonPath("$.sellerId").value(sellerId)) + .andExpect(jsonPath("$.seller.id").value(sellerId)) .andExpect(jsonPath("$.images").isArray()) .andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size())) .andExpect(jsonPath("$.hashtags").isArray()) @@ -479,7 +479,7 @@ public InstrumentControllerTest(MockMvc mvc) { ) .andExpect(status().isCreated()) .andExpect(jsonPath("$.id").value(expectedResult.getId())) - .andExpect(jsonPath("$.sellerId").value(sellerId)) + .andExpect(jsonPath("$.seller.id").value(sellerId)) .andExpect(jsonPath("$.images").isArray()) .andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size())) .andExpect(jsonPath("$.hashtags").isArray()) @@ -525,7 +525,7 @@ public InstrumentControllerTest(MockMvc mvc) { ) .andExpect(status().isCreated()) .andExpect(jsonPath("$.id").value(expectedResult.getId())) - .andExpect(jsonPath("$.sellerId").value(sellerId)) + .andExpect(jsonPath("$.seller.id").value(sellerId)) .andExpect(jsonPath("$.images").isArray()) .andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size())) .andExpect(jsonPath("$.hashtags").isArray()) @@ -569,7 +569,7 @@ public InstrumentControllerTest(MockMvc mvc) { ) .andExpect(status().isCreated()) .andExpect(jsonPath("$.id").value(expectedResult.getId())) - .andExpect(jsonPath("$.sellerId").value(sellerId)) + .andExpect(jsonPath("$.seller.id").value(sellerId)) .andExpect(jsonPath("$.images").isArray()) .andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size())) .andExpect(jsonPath("$.hashtags").isArray()) @@ -612,7 +612,7 @@ public InstrumentControllerTest(MockMvc mvc) { ) .andExpect(status().isCreated()) .andExpect(jsonPath("$.id").value(expectedResult.getId())) - .andExpect(jsonPath("$.sellerId").value(sellerId)) + .andExpect(jsonPath("$.seller.id").value(sellerId)) .andExpect(jsonPath("$.images").isArray()) .andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size())) .andExpect(jsonPath("$.hashtags").isArray()) @@ -653,7 +653,7 @@ public InstrumentControllerTest(MockMvc mvc) { ) .andExpect(status().isCreated()) .andExpect(jsonPath("$.id").value(expectedResult.getId())) - .andExpect(jsonPath("$.sellerId").value(sellerId)) + .andExpect(jsonPath("$.seller.id").value(sellerId)) .andExpect(jsonPath("$.images").isArray()) .andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size())) .andExpect(jsonPath("$.hashtags").isArray())