Skip to content

Commit 6232783

Browse files
committed
feat: #110 악기 매물 단건 조회 API 응답 데이터에 판매자 정보 추가
1 parent 77c5088 commit 6232783

File tree

8 files changed

+45
-27
lines changed

8 files changed

+45
-27
lines changed

src/main/java/com/ajou/hertz/domain/instrument/acoustic_and_classic_guitar/dto/response/AcousticAndClassicGuitarResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class AcousticAndClassicGuitarResponse extends InstrumentResponse {
3636

3737
private AcousticAndClassicGuitarResponse(
3838
Long id,
39-
Long sellerId,
39+
SellerResponse seller,
4040
String title,
4141
InstrumentProgressStatus progressStatus,
4242
AddressResponse tradeAddress,
@@ -52,7 +52,7 @@ private AcousticAndClassicGuitarResponse(
5252
AcousticAndClassicGuitarPickUp pickUp
5353
) {
5454
super(
55-
id, sellerId, InstrumentCategory.ACOUSTIC_AND_CLASSIC_GUITAR, title, progressStatus, tradeAddress,
55+
id, seller, InstrumentCategory.ACOUSTIC_AND_CLASSIC_GUITAR, title, progressStatus, tradeAddress,
5656
qualityStatus, price, hasAnomaly, description, images, hashtags
5757
);
5858
this.brand = brand;

src/main/java/com/ajou/hertz/domain/instrument/amplifier/dto/response/AmplifierResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class AmplifierResponse extends InstrumentResponse {
3232

3333
private AmplifierResponse(
3434
Long id,
35-
Long sellerId,
35+
SellerResponse seller,
3636
String title,
3737
InstrumentProgressStatus progressStatus,
3838
AddressResponse tradeAddress,
@@ -47,7 +47,7 @@ private AmplifierResponse(
4747
AmplifierUsage usage
4848
) {
4949
super(
50-
id, sellerId, InstrumentCategory.AMPLIFIER, title, progressStatus, tradeAddress,
50+
id, seller, InstrumentCategory.AMPLIFIER, title, progressStatus, tradeAddress,
5151
qualityStatus, price, hasAnomaly, description, images, hashtags
5252
);
5353
this.type = type;

src/main/java/com/ajou/hertz/domain/instrument/audio_equipment/dto/response/AudioEquipmentResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class AudioEquipmentResponse extends InstrumentResponse {
2424

2525
private AudioEquipmentResponse(
2626
Long id,
27-
Long sellerId,
27+
SellerResponse seller,
2828
String title,
2929
InstrumentProgressStatus progressStatus,
3030
AddressResponse tradeAddress,
@@ -37,7 +37,7 @@ private AudioEquipmentResponse(
3737
AudioEquipmentType type
3838
) {
3939
super(
40-
id, sellerId, InstrumentCategory.AUDIO_EQUIPMENT, title, progressStatus, tradeAddress,
40+
id, seller, InstrumentCategory.AUDIO_EQUIPMENT, title, progressStatus, tradeAddress,
4141
qualityStatus, price, hasAnomaly, description, images, hashtags
4242
);
4343
this.type = type;

src/main/java/com/ajou/hertz/domain/instrument/bass_guitar/dto/response/BassGuitarResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class BassGuitarResponse extends InstrumentResponse {
3636

3737
private BassGuitarResponse(
3838
Long id,
39-
Long sellerId,
39+
SellerResponse seller,
4040
String title,
4141
InstrumentProgressStatus progressStatus,
4242
AddressResponse tradeAddress,
@@ -52,7 +52,7 @@ private BassGuitarResponse(
5252
GuitarColor color
5353
) {
5454
super(
55-
id, sellerId, InstrumentCategory.BASS_GUITAR, title, progressStatus, tradeAddress,
55+
id, seller, InstrumentCategory.BASS_GUITAR, title, progressStatus, tradeAddress,
5656
qualityStatus, price, hasAnomaly, description, images, hashtags
5757
);
5858
this.brand = brand;

src/main/java/com/ajou/hertz/domain/instrument/dto/response/InstrumentResponse.java

+26-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package com.ajou.hertz.domain.instrument.dto.response;
22

3-
import java.util.List;
4-
53
import com.ajou.hertz.common.dto.response.AddressResponse;
64
import com.ajou.hertz.domain.instrument.constant.InstrumentCategory;
75
import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus;
86
import com.ajou.hertz.domain.instrument.dto.InstrumentDto;
9-
7+
import com.ajou.hertz.domain.user.dto.UserDto;
108
import io.swagger.v3.oas.annotations.media.Schema;
119
import lombok.AccessLevel;
1210
import lombok.AllArgsConstructor;
1311
import lombok.Getter;
1412
import lombok.NoArgsConstructor;
1513

14+
import java.util.List;
15+
1616
@AllArgsConstructor(access = AccessLevel.PROTECTED)
1717
@NoArgsConstructor(access = AccessLevel.PROTECTED)
1818
@Getter
@@ -21,8 +21,8 @@ public abstract class InstrumentResponse {
2121
@Schema(description = "Id of instrument", example = "2")
2222
private Long id;
2323

24-
@Schema(description = "Id of seller", example = "1")
25-
private Long sellerId;
24+
@Schema(description = "판매자 정보")
25+
private SellerResponse seller;
2626

2727
@Schema(description = "종류")
2828
private InstrumentCategory category;
@@ -56,7 +56,7 @@ public abstract class InstrumentResponse {
5656

5757
protected InstrumentResponse(InstrumentDto instrumentDto) {
5858
this.id = instrumentDto.getId();
59-
this.sellerId = instrumentDto.getSeller().getId();
59+
this.seller = SellerResponse.from(instrumentDto.getSeller());
6060
this.category = instrumentDto.getCategory();
6161
this.title = instrumentDto.getTitle();
6262
this.progressStatus = instrumentDto.getProgressStatus();
@@ -66,8 +66,26 @@ protected InstrumentResponse(InstrumentDto instrumentDto) {
6666
this.hasAnomaly = instrumentDto.getHasAnomaly();
6767
this.description = instrumentDto.getDescription();
6868
this.images = instrumentDto.getImages().stream()
69-
.map(InstrumentImageResponse::from)
70-
.toList();
69+
.map(InstrumentImageResponse::from)
70+
.toList();
7171
this.hashtags = instrumentDto.getHashtags();
7272
}
73+
74+
public record SellerResponse(
75+
@Schema(
76+
description = "Id of user",
77+
example = "1"
78+
) Long id,
79+
@Schema(
80+
description = "연락 수단",
81+
example = "https://contack-link"
82+
) String contactLink
83+
) {
84+
private static SellerResponse from(UserDto userDto) {
85+
return new SellerResponse(
86+
userDto.getId(),
87+
userDto.getContactLink()
88+
);
89+
}
90+
}
7391
}

src/main/java/com/ajou/hertz/domain/instrument/effector/dto/response/EffectorResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class EffectorResponse extends InstrumentResponse {
2828

2929
private EffectorResponse(
3030
Long id,
31-
Long sellerId,
31+
SellerResponse seller,
3232
String title,
3333
InstrumentProgressStatus progressStatus,
3434
AddressResponse tradeAddress,
@@ -42,7 +42,7 @@ private EffectorResponse(
4242
EffectorFeature feature
4343
) {
4444
super(
45-
id, sellerId, InstrumentCategory.EFFECTOR, title, progressStatus, tradeAddress,
45+
id, seller, InstrumentCategory.EFFECTOR, title, progressStatus, tradeAddress,
4646
qualityStatus, price, hasAnomaly, description, images, hashtags
4747
);
4848
this.type = type;

src/main/java/com/ajou/hertz/domain/instrument/electric_guitar/dto/response/ElectricGuitarResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class ElectricGuitarResponse extends InstrumentResponse {
3535

3636
private ElectricGuitarResponse(
3737
Long id,
38-
Long sellerId,
38+
SellerResponse seller,
3939
String title,
4040
InstrumentProgressStatus progressStatus,
4141
AddressResponse tradeAddress,
@@ -51,7 +51,7 @@ private ElectricGuitarResponse(
5151
GuitarColor color
5252
) {
5353
super(
54-
id, sellerId, InstrumentCategory.ELECTRIC_GUITAR, title, progressStatus, tradeAddress,
54+
id, seller, InstrumentCategory.ELECTRIC_GUITAR, title, progressStatus, tradeAddress,
5555
qualityStatus, price, hasAnomaly, description, images, hashtags
5656
);
5757
this.brand = brand;

src/test/java/com/ajou/hertz/unit/domain/instrument/controller/InstrumentControllerTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public InstrumentControllerTest(MockMvc mvc) {
110110
)
111111
.andExpect(status().isOk())
112112
.andExpect(jsonPath("$.id").value(expectedResult.getId()))
113-
.andExpect(jsonPath("$.sellerId").value(expectedResult.getSeller().getId()))
113+
.andExpect(jsonPath("$.seller.id").value(expectedResult.getSeller().getId()))
114114
.andExpect(jsonPath("$.category").value(expectedResult.getCategory().name()));
115115
then(instrumentQueryService).should().getInstrumentDtoById(instrumentId);
116116
verifyEveryMocksShouldHaveNoMoreInteractions();
@@ -433,7 +433,7 @@ public InstrumentControllerTest(MockMvc mvc) {
433433
)
434434
.andExpect(status().isCreated())
435435
.andExpect(jsonPath("$.id").value(expectedResult.getId()))
436-
.andExpect(jsonPath("$.sellerId").value(sellerId))
436+
.andExpect(jsonPath("$.seller.id").value(sellerId))
437437
.andExpect(jsonPath("$.images").isArray())
438438
.andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size()))
439439
.andExpect(jsonPath("$.hashtags").isArray())
@@ -479,7 +479,7 @@ public InstrumentControllerTest(MockMvc mvc) {
479479
)
480480
.andExpect(status().isCreated())
481481
.andExpect(jsonPath("$.id").value(expectedResult.getId()))
482-
.andExpect(jsonPath("$.sellerId").value(sellerId))
482+
.andExpect(jsonPath("$.seller.id").value(sellerId))
483483
.andExpect(jsonPath("$.images").isArray())
484484
.andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size()))
485485
.andExpect(jsonPath("$.hashtags").isArray())
@@ -525,7 +525,7 @@ public InstrumentControllerTest(MockMvc mvc) {
525525
)
526526
.andExpect(status().isCreated())
527527
.andExpect(jsonPath("$.id").value(expectedResult.getId()))
528-
.andExpect(jsonPath("$.sellerId").value(sellerId))
528+
.andExpect(jsonPath("$.seller.id").value(sellerId))
529529
.andExpect(jsonPath("$.images").isArray())
530530
.andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size()))
531531
.andExpect(jsonPath("$.hashtags").isArray())
@@ -569,7 +569,7 @@ public InstrumentControllerTest(MockMvc mvc) {
569569
)
570570
.andExpect(status().isCreated())
571571
.andExpect(jsonPath("$.id").value(expectedResult.getId()))
572-
.andExpect(jsonPath("$.sellerId").value(sellerId))
572+
.andExpect(jsonPath("$.seller.id").value(sellerId))
573573
.andExpect(jsonPath("$.images").isArray())
574574
.andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size()))
575575
.andExpect(jsonPath("$.hashtags").isArray())
@@ -612,7 +612,7 @@ public InstrumentControllerTest(MockMvc mvc) {
612612
)
613613
.andExpect(status().isCreated())
614614
.andExpect(jsonPath("$.id").value(expectedResult.getId()))
615-
.andExpect(jsonPath("$.sellerId").value(sellerId))
615+
.andExpect(jsonPath("$.seller.id").value(sellerId))
616616
.andExpect(jsonPath("$.images").isArray())
617617
.andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size()))
618618
.andExpect(jsonPath("$.hashtags").isArray())
@@ -653,7 +653,7 @@ public InstrumentControllerTest(MockMvc mvc) {
653653
)
654654
.andExpect(status().isCreated())
655655
.andExpect(jsonPath("$.id").value(expectedResult.getId()))
656-
.andExpect(jsonPath("$.sellerId").value(sellerId))
656+
.andExpect(jsonPath("$.seller.id").value(sellerId))
657657
.andExpect(jsonPath("$.images").isArray())
658658
.andExpect(jsonPath("$.images.size()").value(expectedResult.getImages().size()))
659659
.andExpect(jsonPath("$.hashtags").isArray())

0 commit comments

Comments
 (0)