Skip to content

Commit

Permalink
feat: #80 악기 response DTO에 카테고리 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Wo-ogie committed Mar 13, 2024
1 parent 35bc9f7 commit 6d090c8
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ajou.hertz.domain.instrument.constant.AcousticAndClassicGuitarModel;
import com.ajou.hertz.domain.instrument.constant.AcousticAndClassicGuitarPickUp;
import com.ajou.hertz.domain.instrument.constant.AcousticAndClassicGuitarWood;
import com.ajou.hertz.domain.instrument.constant.InstrumentCategory;
import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus;
import com.ajou.hertz.domain.instrument.dto.AcousticAndClassicGuitarDto;

Expand Down Expand Up @@ -49,33 +50,24 @@ private AcousticAndClassicGuitarResponse(
AcousticAndClassicGuitarPickUp pickUp
) {
super(
id, sellerId, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, sellerId, InstrumentCategory.ACOUSTIC_AND_CLASSIC_GUITAR, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.brand = brand;
this.model = model;
this.wood = wood;
this.pickUp = pickUp;
}

private AcousticAndClassicGuitarResponse(AcousticAndClassicGuitarDto acousticAndClassicGuitarDto) {
super(acousticAndClassicGuitarDto);
this.brand = acousticAndClassicGuitarDto.getBrand();
this.model = acousticAndClassicGuitarDto.getModel();
this.wood = acousticAndClassicGuitarDto.getWood();
this.pickUp = acousticAndClassicGuitarDto.getPickUp();
}

public static AcousticAndClassicGuitarResponse from(AcousticAndClassicGuitarDto acousticAndClassicGuitarDto) {
InstrumentResponse instrumentResponse = InstrumentResponse.from(acousticAndClassicGuitarDto);
return new AcousticAndClassicGuitarResponse(
instrumentResponse.getId(),
instrumentResponse.getSellerId(),
instrumentResponse.getTitle(),
instrumentResponse.getProgressStatus(),
instrumentResponse.getTradeAddress(),
instrumentResponse.getQualityStatus(),
instrumentResponse.getPrice(),
instrumentResponse.getHasAnomaly(),
instrumentResponse.getDescription(),
instrumentResponse.getImages(),
instrumentResponse.getHashtags(),
acousticAndClassicGuitarDto.getBrand(),
acousticAndClassicGuitarDto.getModel(),
acousticAndClassicGuitarDto.getWood(),
acousticAndClassicGuitarDto.getPickUp()
);
return new AcousticAndClassicGuitarResponse(acousticAndClassicGuitarDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.ajou.hertz.domain.instrument.constant.AmplifierBrand;
import com.ajou.hertz.domain.instrument.constant.AmplifierType;
import com.ajou.hertz.domain.instrument.constant.AmplifierUsage;
import com.ajou.hertz.domain.instrument.constant.InstrumentCategory;
import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus;
import com.ajou.hertz.domain.instrument.dto.AmplifierDto;

Expand Down Expand Up @@ -44,31 +45,22 @@ private AmplifierResponse(
AmplifierUsage usage
) {
super(
id, sellerId, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, sellerId, InstrumentCategory.AMPLIFIER, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.type = type;
this.brand = brand;
this.usage = usage;
}

private AmplifierResponse(AmplifierDto amplifierDto) {
super(amplifierDto);
this.type = amplifierDto.getType();
this.brand = amplifierDto.getBrand();
this.usage = amplifierDto.getUsage();
}

public static AmplifierResponse from(AmplifierDto amplifierDto) {
InstrumentResponse instrumentResponse = InstrumentResponse.from(amplifierDto);
return new AmplifierResponse(
instrumentResponse.getId(),
instrumentResponse.getSellerId(),
instrumentResponse.getTitle(),
instrumentResponse.getProgressStatus(),
instrumentResponse.getTradeAddress(),
instrumentResponse.getQualityStatus(),
instrumentResponse.getPrice(),
instrumentResponse.getHasAnomaly(),
instrumentResponse.getDescription(),
instrumentResponse.getImages(),
instrumentResponse.getHashtags(),
amplifierDto.getType(),
amplifierDto.getBrand(),
amplifierDto.getUsage()
);
return new AmplifierResponse(amplifierDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.ajou.hertz.common.dto.response.AddressResponse;
import com.ajou.hertz.domain.instrument.constant.AudioEquipmentType;
import com.ajou.hertz.domain.instrument.constant.InstrumentCategory;
import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus;
import com.ajou.hertz.domain.instrument.dto.AudioEquipmentDto;

Expand Down Expand Up @@ -34,27 +35,18 @@ private AudioEquipmentResponse(
AudioEquipmentType type
) {
super(
id, sellerId, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, sellerId, InstrumentCategory.AUDIO_EQUIPMENT, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.type = type;
}

private AudioEquipmentResponse(AudioEquipmentDto audioEquipmentDto) {
super(audioEquipmentDto);
this.type = audioEquipmentDto.getType();
}

public static AudioEquipmentResponse from(AudioEquipmentDto audioEquipmentDto) {
InstrumentResponse instrumentResponse = InstrumentResponse.from(audioEquipmentDto);
return new AudioEquipmentResponse(
instrumentResponse.getId(),
instrumentResponse.getSellerId(),
instrumentResponse.getTitle(),
instrumentResponse.getProgressStatus(),
instrumentResponse.getTradeAddress(),
instrumentResponse.getQualityStatus(),
instrumentResponse.getPrice(),
instrumentResponse.getHasAnomaly(),
instrumentResponse.getDescription(),
instrumentResponse.getImages(),
instrumentResponse.getHashtags(),
audioEquipmentDto.getType()
);
return new AudioEquipmentResponse(audioEquipmentDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ajou.hertz.domain.instrument.constant.BassGuitarPickUp;
import com.ajou.hertz.domain.instrument.constant.BassGuitarPreAmplifier;
import com.ajou.hertz.domain.instrument.constant.GuitarColor;
import com.ajou.hertz.domain.instrument.constant.InstrumentCategory;
import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus;
import com.ajou.hertz.domain.instrument.dto.BassGuitarDto;

Expand Down Expand Up @@ -49,33 +50,24 @@ private BassGuitarResponse(
GuitarColor color
) {
super(
id, sellerId, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, sellerId, InstrumentCategory.BASS_GUITAR, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.brand = brand;
this.pickUp = pickUp;
this.preAmplifier = preAmplifier;
this.color = color;
}

private BassGuitarResponse(BassGuitarDto bassGuitarDto) {
super(bassGuitarDto);
this.brand = bassGuitarDto.getBrand();
this.pickUp = bassGuitarDto.getPickUp();
this.preAmplifier = bassGuitarDto.getPreAmplifier();
this.color = bassGuitarDto.getColor();
}

public static BassGuitarResponse from(BassGuitarDto bassGuitarDto) {
InstrumentResponse instrumentResponse = InstrumentResponse.from(bassGuitarDto);
return new BassGuitarResponse(
instrumentResponse.getId(),
instrumentResponse.getSellerId(),
instrumentResponse.getTitle(),
instrumentResponse.getProgressStatus(),
instrumentResponse.getTradeAddress(),
instrumentResponse.getQualityStatus(),
instrumentResponse.getPrice(),
instrumentResponse.getHasAnomaly(),
instrumentResponse.getDescription(),
instrumentResponse.getImages(),
instrumentResponse.getHashtags(),
bassGuitarDto.getBrand(),
bassGuitarDto.getPickUp(),
bassGuitarDto.getPreAmplifier(),
bassGuitarDto.getColor()
);
return new BassGuitarResponse(bassGuitarDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.ajou.hertz.common.dto.response.AddressResponse;
import com.ajou.hertz.domain.instrument.constant.EffectorFeature;
import com.ajou.hertz.domain.instrument.constant.EffectorType;
import com.ajou.hertz.domain.instrument.constant.InstrumentCategory;
import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus;
import com.ajou.hertz.domain.instrument.dto.EffectorDto;

Expand Down Expand Up @@ -39,29 +40,20 @@ private EffectorResponse(
EffectorFeature feature
) {
super(
id, sellerId, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, sellerId, InstrumentCategory.EFFECTOR, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.type = type;
this.feature = feature;
}

private EffectorResponse(EffectorDto effectorDto) {
super(effectorDto);
this.type = effectorDto.getType();
this.feature = effectorDto.getFeature();
}

public static EffectorResponse from(EffectorDto effectorDto) {
InstrumentResponse instrumentResponse = InstrumentResponse.from(effectorDto);
return new EffectorResponse(
instrumentResponse.getId(),
instrumentResponse.getSellerId(),
instrumentResponse.getTitle(),
instrumentResponse.getProgressStatus(),
instrumentResponse.getTradeAddress(),
instrumentResponse.getQualityStatus(),
instrumentResponse.getPrice(),
instrumentResponse.getHasAnomaly(),
instrumentResponse.getDescription(),
instrumentResponse.getImages(),
instrumentResponse.getHashtags(),
effectorDto.getType(),
effectorDto.getFeature()
);
return new EffectorResponse(effectorDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.ajou.hertz.domain.instrument.constant.ElectricGuitarBrand;
import com.ajou.hertz.domain.instrument.constant.ElectricGuitarModel;
import com.ajou.hertz.domain.instrument.constant.GuitarColor;
import com.ajou.hertz.domain.instrument.constant.InstrumentCategory;
import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus;
import com.ajou.hertz.domain.instrument.dto.ElectricGuitarDto;

Expand Down Expand Up @@ -48,32 +49,24 @@ private ElectricGuitarResponse(
GuitarColor color
) {
super(
id, sellerId, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags);
id, sellerId, InstrumentCategory.ELECTRIC_GUITAR, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.brand = brand;
this.model = model;
this.productionYear = productionYear;
this.color = color;
}

private ElectricGuitarResponse(ElectricGuitarDto electricGuitarDto) {
super(electricGuitarDto);
this.brand = electricGuitarDto.getBrand();
this.model = electricGuitarDto.getModel();
this.productionYear = electricGuitarDto.getProductionYear();
this.color = electricGuitarDto.getColor();
}

public static ElectricGuitarResponse from(ElectricGuitarDto electricGuitarDto) {
InstrumentResponse instrumentResponse = InstrumentResponse.from(electricGuitarDto);
return new ElectricGuitarResponse(
instrumentResponse.getId(),
instrumentResponse.getSellerId(),
instrumentResponse.getTitle(),
instrumentResponse.getProgressStatus(),
instrumentResponse.getTradeAddress(),
instrumentResponse.getQualityStatus(),
instrumentResponse.getPrice(),
instrumentResponse.getHasAnomaly(),
instrumentResponse.getDescription(),
instrumentResponse.getImages(),
instrumentResponse.getHashtags(),
electricGuitarDto.getBrand(),
electricGuitarDto.getModel(),
electricGuitarDto.getProductionYear(),
electricGuitarDto.getColor()
);
return new ElectricGuitarResponse(electricGuitarDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;

Expand All @@ -15,14 +16,17 @@
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class InstrumentResponse {
public abstract class InstrumentResponse {

@Schema(description = "Id of instrument(electric guitar)", example = "2")
private Long id;

@Schema(description = "Id of seller", example = "1")
private Long sellerId;

@Schema(description = "종류")
private InstrumentCategory category;

@Schema(description = "제목", example = "펜더 로드원 텔레캐스터")
private String title;

Expand Down Expand Up @@ -50,22 +54,40 @@ public class InstrumentResponse {
@Schema(description = "해시태그", example = "[\"펜더\", \"Fender\"]")
private List<String> hashtags;

public static InstrumentResponse from(InstrumentDto instrumentDto) {
return new InstrumentResponse(
instrumentDto.getId(),
instrumentDto.getSeller().getId(),
instrumentDto.getTitle(),
instrumentDto.getProgressStatus(),
AddressResponse.from(instrumentDto.getTradeAddress()),
instrumentDto.getQualityStatus(),
instrumentDto.getPrice(),
instrumentDto.getHasAnomaly(),
instrumentDto.getDescription(),
instrumentDto.getImages()
.stream()
.map(InstrumentImageResponse::from)
.toList(),
instrumentDto.getHashtags()
);
protected InstrumentResponse(InstrumentDto instrumentDto) {
this.id = instrumentDto.getId();
this.sellerId = instrumentDto.getSeller().getId();
this.category = instrumentDto.getCategory();
this.title = instrumentDto.getTitle();
this.progressStatus = instrumentDto.getProgressStatus();
this.tradeAddress = AddressResponse.from(instrumentDto.getTradeAddress());
this.qualityStatus = instrumentDto.getQualityStatus();
this.price = instrumentDto.getPrice();
this.hasAnomaly = instrumentDto.getHasAnomaly();
this.description = instrumentDto.getDescription();
this.images = instrumentDto.getImages().stream()
.map(InstrumentImageResponse::from)
.toList();
this.hashtags = instrumentDto.getHashtags();
}

// public static InstrumentResponse from(InstrumentDto instrumentDto) {
// return new InstrumentResponse(
// instrumentDto.getId(),
// instrumentDto.getSeller().getId(),
// instrumentDto.getCategory(),
// instrumentDto.getTitle(),
// instrumentDto.getProgressStatus(),
// AddressResponse.from(instrumentDto.getTradeAddress()),
// instrumentDto.getQualityStatus(),
// instrumentDto.getPrice(),
// instrumentDto.getHasAnomaly(),
// instrumentDto.getDescription(),
// instrumentDto.getImages()
// .stream()
// .map(InstrumentImageResponse::from)
// .toList(),
// instrumentDto.getHashtags()
// );
// }
}
Loading

0 comments on commit 6d090c8

Please sign in to comment.