diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/request/CardCreateRequestDTO.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/request/CardCreateRequestDTO.java new file mode 100644 index 00000000..8f5fff5c --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/request/CardCreateRequestDTO.java @@ -0,0 +1,22 @@ +package org.prgrms.nabimarketbe.domain.card.dto.request; + +import org.prgrms.nabimarketbe.domain.card.entity.TradeType; +import org.prgrms.nabimarketbe.domain.cardimage.dto.request.CardImageCreateRequestDTO; +import org.prgrms.nabimarketbe.domain.category.entity.CategoryEnum; +import org.prgrms.nabimarketbe.domain.item.entity.PriceRange; + +import java.util.List; + +public record CardCreateRequestDTO( + String title, + String thumbNailImage, + String name, + PriceRange priceRange, + TradeType tradeType, + CategoryEnum category, + String tradeArea, + Boolean pokeAvailable, + String content, + List images +) { +} diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardCreateResponseDTO.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardCreateResponseDTO.java new file mode 100644 index 00000000..e2d40605 --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardCreateResponseDTO.java @@ -0,0 +1,65 @@ +package org.prgrms.nabimarketbe.domain.card.dto.response; + +import lombok.Builder; +import org.prgrms.nabimarketbe.domain.card.entity.TradeType; +import org.prgrms.nabimarketbe.domain.cardimage.dto.response.CardImageCreateResponseDTO; +import org.prgrms.nabimarketbe.domain.category.entity.CategoryEnum; +import org.prgrms.nabimarketbe.domain.item.entity.PriceRange; + +import java.time.LocalDateTime; +import java.util.List; + +@Builder +public record CardCreateResponseDTO( + Long cardId, + String title, + String thumbNailImage, + String name, + PriceRange priceRange, + TradeType tradeType, + CategoryEnum category, + String tradeArea, + Boolean pokeAvailable, + String content, + Integer viewCount, + Integer dibCount, + LocalDateTime createdAt, + LocalDateTime modifiedAt, + List images +) { + public static CardCreateResponseDTO of( + Long cardId, + String title, + String thumbNailImage, + String name, + PriceRange priceRange, + TradeType tradeType, + CategoryEnum category, + String tradeArea, + Boolean pokeAvailable, + String content, + Integer viewCount, + Integer dibCount, + LocalDateTime createdAt, + LocalDateTime modifiedAt, + List images + ) { + return CardCreateResponseDTO.builder() + .cardId(cardId) + .title(title) + .thumbNailImage(thumbNailImage) + .name(name) + .priceRange(priceRange) + .tradeType(tradeType) + .category(category) + .tradeArea(tradeArea) + .pokeAvailable(pokeAvailable) + .content(content) + .viewCount(viewCount) + .dibCount(dibCount) + .createdAt(createdAt) + .modifiedAt(modifiedAt) + .images(images) + .build(); + } +} diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardSingleReadResponseDTO.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardSingleReadResponseDTO.java new file mode 100644 index 00000000..c8bf711b --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardSingleReadResponseDTO.java @@ -0,0 +1,59 @@ +package org.prgrms.nabimarketbe.domain.card.dto.response; + +import lombok.Builder; +import org.prgrms.nabimarketbe.domain.card.entity.CardStatus; +import org.prgrms.nabimarketbe.domain.card.entity.TradeType; +import org.prgrms.nabimarketbe.domain.cardimage.dto.response.CardImageSingleReadResponseDTO; +import org.prgrms.nabimarketbe.domain.category.entity.CategoryEnum; +import org.prgrms.nabimarketbe.domain.item.entity.PriceRange; + +import java.util.List; + +@Builder +public record CardSingleReadResponseDTO( + Long cardId, + String cardTitle, + String content, + String tradeArea, + Boolean pokeAvailable, + TradeType tradeType, + CardStatus status, + Integer viewCount, + Integer dibCount, + String itemName, + CategoryEnum category, + PriceRange priceRange, + List images +) { + public static CardSingleReadResponseDTO of( + Long cardId, + String cardTitle, + String content, + String tradeArea, + Boolean pokeAvailable, + TradeType tradeType, + CardStatus status, + Integer viewCount, + Integer dibCount, + String itemName, + CategoryEnum category, + PriceRange priceRange, + List images + ) { + return CardSingleReadResponseDTO.builder() + .cardId(cardId) + .cardTitle(cardTitle) + .content(content) + .tradeArea(tradeArea) + .pokeAvailable(pokeAvailable) + .tradeType(tradeType) + .status(status) + .viewCount(viewCount) + .dibCount(dibCount) + .itemName(itemName) + .category(category) + .priceRange(priceRange) + .images(images) + .build(); + } +} diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/Card.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/Card.java new file mode 100644 index 00000000..13b1b813 --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/Card.java @@ -0,0 +1,69 @@ +package org.prgrms.nabimarketbe.domain.card.entity; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.prgrms.nabimarketbe.global.BaseEntity; +import org.prgrms.nabimarketbe.domain.item.entity.Item; + +import javax.persistence.*; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Entity +@Table +@Getter +@NoArgsConstructor +public class Card extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long cardId; + + @NotNull @NotBlank + private String cardTitle; + + private String thumbNailImage; + + @Lob + private String content; + + private String tradeArea; + + private Boolean poke; + + @Enumerated(EnumType.STRING) + private TradeType tradeType; + + @Enumerated(EnumType.STRING) + private CardStatus status; + + private Integer viewCount; + + private Integer dibCount; + + @OneToOne + @JoinColumn(name = "item_id") + private Item item; + + @Builder + public Card( + String cardTitle, + String thumbNailImage, + String content, + String tradeArea, + Boolean poke, + TradeType tradeType, + Item item + ) { + this.cardTitle = cardTitle; + this.thumbNailImage = thumbNailImage; + this.content = content; + this.tradeArea = tradeArea; + this.poke = poke; + this.tradeType = tradeType; + this.status = CardStatus.TRADE_AVAILABLE; + this.viewCount = 0; + this.dibCount = 0; + this.item = item; + } +} diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/CardStatus.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/CardStatus.java new file mode 100644 index 00000000..101c87e8 --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/CardStatus.java @@ -0,0 +1,7 @@ +package org.prgrms.nabimarketbe.domain.card.entity; + +public enum CardStatus { + TRADE_AVAILABLE, + RESERVED, + TRADE_COMPLETE +} diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/TradeType.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/TradeType.java new file mode 100644 index 00000000..b5d91493 --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/entity/TradeType.java @@ -0,0 +1,6 @@ +package org.prgrms.nabimarketbe.domain.card.entity; + +public enum TradeType { + DIRECT_DEALING, + SHIPPING +} diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepository.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepository.java new file mode 100644 index 00000000..7848eef7 --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepository.java @@ -0,0 +1,7 @@ +package org.prgrms.nabimarketbe.domain.card.repository; + +import org.prgrms.nabimarketbe.domain.card.entity.Card; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface CardRepository extends JpaRepository, CardRepositoryCustom { +} diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryCustom.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryCustom.java new file mode 100644 index 00000000..2499aa85 --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryCustom.java @@ -0,0 +1,5 @@ +package org.prgrms.nabimarketbe.domain.card.repository; + +public interface CardRepositoryCustom { + +} diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryImpl.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryImpl.java new file mode 100644 index 00000000..35c31be3 --- /dev/null +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryImpl.java @@ -0,0 +1,4 @@ +package org.prgrms.nabimarketbe.domain.card.repository; + +public class CardRepositoryImpl implements CardRepositoryCustom { +}