-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
베이스 기타 매물 생성 API 구현
- Loading branch information
Showing
16 changed files
with
837 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/com/ajou/hertz/domain/instrument/dto/BassGuitarDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.ajou.hertz.domain.instrument.dto; | ||
|
||
import java.util.List; | ||
|
||
import com.ajou.hertz.common.dto.AddressDto; | ||
import com.ajou.hertz.domain.instrument.constant.BassGuitarBrand; | ||
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.InstrumentProgressStatus; | ||
import com.ajou.hertz.domain.instrument.entity.BassGuitar; | ||
import com.ajou.hertz.domain.user.dto.UserDto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class BassGuitarDto extends InstrumentDto { | ||
|
||
private BassGuitarBrand brand; | ||
private BassGuitarPickUp pickUp; | ||
private BassGuitarPreAmplifier preAmplifier; | ||
private GuitarColor color; | ||
|
||
private BassGuitarDto( | ||
Long id, | ||
UserDto seller, | ||
String title, | ||
InstrumentProgressStatus progressStatus, | ||
AddressDto tradeAddress, | ||
Short qualityStatus, | ||
Integer price, | ||
Boolean hasAnomaly, | ||
String description, | ||
List<InstrumentImageDto> images, | ||
List<String> hashtags, | ||
BassGuitarBrand brand, | ||
BassGuitarPickUp pickUp, | ||
BassGuitarPreAmplifier preAmplifier, | ||
GuitarColor color | ||
) { | ||
super( | ||
id, seller, title, progressStatus, tradeAddress, qualityStatus, | ||
price, hasAnomaly, description, images, hashtags | ||
); | ||
this.brand = brand; | ||
this.pickUp = pickUp; | ||
this.preAmplifier = preAmplifier; | ||
this.color = color; | ||
} | ||
|
||
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() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/com/ajou/hertz/domain/instrument/dto/InstrumentDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.ajou.hertz.domain.instrument.dto; | ||
|
||
import java.util.List; | ||
|
||
import com.ajou.hertz.common.dto.AddressDto; | ||
import com.ajou.hertz.domain.instrument.constant.InstrumentProgressStatus; | ||
import com.ajou.hertz.domain.instrument.entity.Instrument; | ||
import com.ajou.hertz.domain.user.dto.UserDto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
public class InstrumentDto { | ||
|
||
private Long id; | ||
private UserDto seller; | ||
private String title; | ||
private InstrumentProgressStatus progressStatus; | ||
private AddressDto tradeAddress; | ||
private Short qualityStatus; | ||
private Integer price; | ||
private Boolean hasAnomaly; | ||
private String description; | ||
private List<InstrumentImageDto> images; | ||
private List<String> hashtags; | ||
|
||
public static InstrumentDto from(Instrument instrument) { | ||
return new InstrumentDto( | ||
instrument.getId(), | ||
UserDto.from(instrument.getSeller()), | ||
instrument.getTitle(), | ||
instrument.getProgressStatus(), | ||
AddressDto.from(instrument.getTradeAddress()), | ||
instrument.getQualityStatus(), | ||
instrument.getPrice(), | ||
instrument.getHasAnomaly(), | ||
instrument.getDescription(), | ||
instrument.getImages().toDtos(), | ||
instrument.getHashtags().toStrings() | ||
); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/ajou/hertz/domain/instrument/dto/request/CreateNewBassGuitarRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.ajou.hertz.domain.instrument.dto.request; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import com.ajou.hertz.common.dto.request.AddressRequest; | ||
import com.ajou.hertz.domain.instrument.constant.BassGuitarBrand; | ||
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.InstrumentProgressStatus; | ||
import com.ajou.hertz.domain.instrument.entity.BassGuitar; | ||
import com.ajou.hertz.domain.user.entity.User; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Setter // for multipart/form-data with @ModelAttribute | ||
@Getter | ||
public class CreateNewBassGuitarRequest extends CreateNewInstrumentRequest<BassGuitar> { | ||
|
||
@NotNull | ||
private BassGuitarBrand brand; | ||
|
||
@NotNull | ||
private BassGuitarPickUp pickUp; | ||
|
||
@NotNull | ||
private BassGuitarPreAmplifier preAmplifier; | ||
|
||
@NotNull | ||
private GuitarColor color; | ||
|
||
private CreateNewBassGuitarRequest( | ||
String title, | ||
InstrumentProgressStatus progressStatus, | ||
AddressRequest tradeAddress, | ||
Short qualityStatus, | ||
Integer price, | ||
Boolean hasAnomaly, | ||
String description, | ||
List<MultipartFile> images, | ||
List<String> hashtags, | ||
BassGuitarBrand brand, | ||
BassGuitarPickUp pickUp, | ||
BassGuitarPreAmplifier preAmplifier, | ||
GuitarColor color | ||
) { | ||
super(title, progressStatus, tradeAddress, qualityStatus, price, hasAnomaly, description, images, hashtags); | ||
this.brand = brand; | ||
this.pickUp = pickUp; | ||
this.preAmplifier = preAmplifier; | ||
this.color = color; | ||
} | ||
|
||
public BassGuitar toEntity(User seller) { | ||
return BassGuitar.create( | ||
seller, | ||
getTitle(), | ||
getProgressStatus(), | ||
getTradeAddress().toEntity(), | ||
getQualityStatus(), | ||
getPrice(), | ||
getHasAnomaly(), | ||
getDescription(), | ||
getBrand(), | ||
getPickUp(), | ||
getPreAmplifier(), | ||
getColor() | ||
); | ||
} | ||
} |
Oops, something went wrong.