Skip to content

Commit

Permalink
feat: card 도메인 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-june committed Nov 2, 2023
1 parent 917ba8d commit c139dbd
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<CardImageCreateRequestDTO> images
) {
}
Original file line number Diff line number Diff line change
@@ -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<CardImageCreateResponseDTO> 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<CardImageCreateResponseDTO> 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();
}
}
Original file line number Diff line number Diff line change
@@ -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<CardImageSingleReadResponseDTO> 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<CardImageSingleReadResponseDTO> 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();
}
}
69 changes: 69 additions & 0 deletions src/main/java/org/prgrms/nabimarketbe/domain/card/entity/Card.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.prgrms.nabimarketbe.domain.card.entity;

public enum CardStatus {
TRADE_AVAILABLE,
RESERVED,
TRADE_COMPLETE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.prgrms.nabimarketbe.domain.card.entity;

public enum TradeType {
DIRECT_DEALING,
SHIPPING
}
Original file line number Diff line number Diff line change
@@ -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<Card, Long>, CardRepositoryCustom {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.prgrms.nabimarketbe.domain.card.repository;

public interface CardRepositoryCustom {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.prgrms.nabimarketbe.domain.card.repository;

public class CardRepositoryImpl implements CardRepositoryCustom {
}

0 comments on commit c139dbd

Please sign in to comment.