Skip to content

Commit

Permalink
feat: #80 악기 DTO에 카테고리 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Wo-ogie committed Mar 13, 2024
1 parent 37972ce commit 35bc9f7
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 134 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.ajou.hertz.domain.instrument.constant;

public enum InstrumentCategory {

ELECTRIC_GUITAR,
BASS_GUITAR,
ACOUSTIC_AND_CLASSIC_GUITAR,
EFFECTOR,
AMPLIFIER,
AUDIO_EQUIPMENT
}
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.entity.AcousticAndClassicGuitar;
import com.ajou.hertz.domain.user.dto.UserDto;
Expand All @@ -24,7 +25,7 @@ public class AcousticAndClassicGuitarDto extends InstrumentDto {
private AcousticAndClassicGuitarWood wood;
private AcousticAndClassicGuitarPickUp pickUp;

private AcousticAndClassicGuitarDto(
public AcousticAndClassicGuitarDto(
Long id,
UserDto seller,
String title,
Expand All @@ -42,33 +43,26 @@ private AcousticAndClassicGuitarDto(
AcousticAndClassicGuitarPickUp pickUp
) {
super(
id, seller, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, seller, 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;
}

public static AcousticAndClassicGuitarDto from(AcousticAndClassicGuitar acousticAndClassicGuitar) {
InstrumentDto instrumentDto = InstrumentDto.from(acousticAndClassicGuitar);
return new AcousticAndClassicGuitarDto(
instrumentDto.getId(),
instrumentDto.getSeller(),
instrumentDto.getTitle(),
instrumentDto.getProgressStatus(),
instrumentDto.getTradeAddress(),
instrumentDto.getQualityStatus(),
instrumentDto.getPrice(),
instrumentDto.getHasAnomaly(),
instrumentDto.getDescription(),
instrumentDto.getImages(),
instrumentDto.getHashtags(),
acousticAndClassicGuitar.getBrand(),
acousticAndClassicGuitar.getModel(),
acousticAndClassicGuitar.getWood(),
acousticAndClassicGuitar.getPickUp()
private AcousticAndClassicGuitarDto(AcousticAndClassicGuitar acousticAndClassicGuitar) {
super(
acousticAndClassicGuitar
);
this.brand = acousticAndClassicGuitar.getBrand();
this.model = acousticAndClassicGuitar.getModel();
this.wood = acousticAndClassicGuitar.getWood();
this.pickUp = acousticAndClassicGuitar.getPickUp();
}

public static AcousticAndClassicGuitarDto from(AcousticAndClassicGuitar acousticAndClassicGuitar) {
return new AcousticAndClassicGuitarDto(acousticAndClassicGuitar);
}
}
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.entity.Amplifier;
import com.ajou.hertz.domain.user.dto.UserDto;
Expand Down Expand Up @@ -39,31 +40,22 @@ private AmplifierDto(
AmplifierUsage usage
) {
super(
id, seller, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, seller, InstrumentCategory.AMPLIFIER, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.type = type;
this.brand = brand;
this.usage = usage;
}

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

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

import com.ajou.hertz.common.dto.AddressDto;
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.entity.AudioEquipment;
import com.ajou.hertz.domain.user.dto.UserDto;
Expand All @@ -18,7 +19,7 @@ public class AudioEquipmentDto extends InstrumentDto {

private AudioEquipmentType type;

private AudioEquipmentDto(
public AudioEquipmentDto(
Long id,
UserDto seller,
String title,
Expand All @@ -33,27 +34,18 @@ private AudioEquipmentDto(
AudioEquipmentType type
) {
super(
id, seller, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, seller, InstrumentCategory.AUDIO_EQUIPMENT, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.type = type;
}

private AudioEquipmentDto(AudioEquipment audioEquipment) {
super(audioEquipment);
this.type = audioEquipment.getType();
}

public static AudioEquipmentDto from(AudioEquipment audioEquipment) {
InstrumentDto instrumentDto = InstrumentDto.from(audioEquipment);
return new AudioEquipmentDto(
instrumentDto.getId(),
instrumentDto.getSeller(),
instrumentDto.getTitle(),
instrumentDto.getProgressStatus(),
instrumentDto.getTradeAddress(),
instrumentDto.getQualityStatus(),
instrumentDto.getPrice(),
instrumentDto.getHasAnomaly(),
instrumentDto.getDescription(),
instrumentDto.getImages(),
instrumentDto.getHashtags(),
audioEquipment.getType()
);
return new AudioEquipmentDto(audioEquipment);
}
}
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.entity.BassGuitar;
import com.ajou.hertz.domain.user.dto.UserDto;
Expand Down Expand Up @@ -42,33 +43,24 @@ private BassGuitarDto(
GuitarColor color
) {
super(
id, seller, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, seller, 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 BassGuitarDto(BassGuitar bassGuitar) {
super(bassGuitar);
this.brand = bassGuitar.getBrand();
this.pickUp = bassGuitar.getPickUp();
this.preAmplifier = bassGuitar.getPreAmplifier();
this.color = bassGuitar.getColor();
}

public static BassGuitarDto from(BassGuitar bassGuitar) {
InstrumentDto instrumentDto = InstrumentDto.from(bassGuitar);
return new BassGuitarDto(
instrumentDto.getId(),
instrumentDto.getSeller(),
instrumentDto.getTitle(),
instrumentDto.getProgressStatus(),
instrumentDto.getTradeAddress(),
instrumentDto.getQualityStatus(),
instrumentDto.getPrice(),
instrumentDto.getHasAnomaly(),
instrumentDto.getDescription(),
instrumentDto.getImages(),
instrumentDto.getHashtags(),
bassGuitar.getBrand(),
bassGuitar.getPickUp(),
bassGuitar.getPreAmplifier(),
bassGuitar.getColor()
);
return new BassGuitarDto(bassGuitar);
}
}
28 changes: 10 additions & 18 deletions src/main/java/com/ajou/hertz/domain/instrument/dto/EffectorDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.ajou.hertz.common.dto.AddressDto;
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.entity.Effector;
import com.ajou.hertz.domain.user.dto.UserDto;
Expand Down Expand Up @@ -36,29 +37,20 @@ private EffectorDto(
EffectorFeature feature
) {
super(
id, seller, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, seller, InstrumentCategory.EFFECTOR, title, progressStatus, tradeAddress,
qualityStatus, price, hasAnomaly, description, images, hashtags
);
this.type = type;
this.feature = feature;
}

private EffectorDto(Effector effector) {
super(effector);
this.type = effector.getType();
this.feature = effector.getFeature();
}

public static EffectorDto from(Effector effector) {
InstrumentDto instrumentDto = InstrumentDto.from(effector);
return new EffectorDto(
instrumentDto.getId(),
instrumentDto.getSeller(),
instrumentDto.getTitle(),
instrumentDto.getProgressStatus(),
instrumentDto.getTradeAddress(),
instrumentDto.getQualityStatus(),
instrumentDto.getPrice(),
instrumentDto.getHasAnomaly(),
instrumentDto.getDescription(),
instrumentDto.getImages(),
instrumentDto.getHashtags(),
effector.getType(),
effector.getFeature()
);
return new EffectorDto(effector);
}
}
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.entity.ElectricGuitar;
import com.ajou.hertz.domain.user.dto.UserDto;
Expand Down Expand Up @@ -33,41 +34,32 @@ private ElectricGuitarDto(
Integer price,
Boolean hasAnomaly,
String description,
List<InstrumentImageDto> images,
List<String> hashtags,
ElectricGuitarBrand brand,
ElectricGuitarModel model,
Short productionYear,
GuitarColor color,
List<InstrumentImageDto> images,
List<String> hashtags
GuitarColor color
) {
super(
id, seller, title, progressStatus, tradeAddress, qualityStatus,
price, hasAnomaly, description, images, hashtags
id, seller, 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 ElectricGuitarDto(ElectricGuitar electricGuitar) {
super(electricGuitar);
this.brand = electricGuitar.getBrand();
this.model = electricGuitar.getModel();
this.productionYear = electricGuitar.getProductionYear();
this.color = electricGuitar.getColor();
}

public static ElectricGuitarDto from(ElectricGuitar electricGuitar) {
InstrumentDto instrumentDto = InstrumentDto.from(electricGuitar);
return new ElectricGuitarDto(
instrumentDto.getId(),
instrumentDto.getSeller(),
instrumentDto.getTitle(),
instrumentDto.getProgressStatus(),
instrumentDto.getTradeAddress(),
instrumentDto.getQualityStatus(),
instrumentDto.getPrice(),
instrumentDto.getHasAnomaly(),
instrumentDto.getDescription(),
electricGuitar.getBrand(),
electricGuitar.getModel(),
electricGuitar.getProductionYear(),
electricGuitar.getColor(),
instrumentDto.getImages(),
instrumentDto.getHashtags()
);
return new ElectricGuitarDto(electricGuitar);
}
}
Loading

0 comments on commit 35bc9f7

Please sign in to comment.