Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

악기 매물 단건 조회 API 응답 데이터에 판매자 정보 추가 #112

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AcousticAndClassicGuitarResponse extends InstrumentResponse {

private AcousticAndClassicGuitarResponse(
Long id,
Long sellerId,
SellerResponse seller,
String title,
InstrumentProgressStatus progressStatus,
AddressResponse tradeAddress,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AmplifierResponse extends InstrumentResponse {

private AmplifierResponse(
Long id,
Long sellerId,
SellerResponse seller,
String title,
InstrumentProgressStatus progressStatus,
AddressResponse tradeAddress,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AudioEquipmentResponse extends InstrumentResponse {

private AudioEquipmentResponse(
Long id,
Long sellerId,
SellerResponse seller,
String title,
InstrumentProgressStatus progressStatus,
AddressResponse tradeAddress,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class BassGuitarResponse extends InstrumentResponse {

private BassGuitarResponse(
Long id,
Long sellerId,
SellerResponse seller,
String title,
InstrumentProgressStatus progressStatus,
AddressResponse tradeAddress,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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()
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class EffectorResponse extends InstrumentResponse {

private EffectorResponse(
Long id,
Long sellerId,
SellerResponse seller,
String title,
InstrumentProgressStatus progressStatus,
AddressResponse tradeAddress,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ElectricGuitarResponse extends InstrumentResponse {

private ElectricGuitarResponse(
Long id,
Long sellerId,
SellerResponse seller,
String title,
InstrumentProgressStatus progressStatus,
AddressResponse tradeAddress,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
Loading