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())