-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ghis22130/model
[BE] Model 설계 closes #4
- Loading branch information
Showing
17 changed files
with
545 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.team10.banchan.model; | ||
|
||
public class Badge { | ||
private final BadgeType badgeType; | ||
|
||
Badge(BadgeType badgeType) { | ||
this.badgeType = badgeType; | ||
} | ||
|
||
public String name() { | ||
return this.badgeType.name; | ||
} | ||
|
||
public static Badge event() { | ||
return new Badge(BadgeType.EVENT); | ||
} | ||
|
||
public static Badge launching() { | ||
return new Badge(BadgeType.LAUNCHING); | ||
} | ||
|
||
enum BadgeType { | ||
EVENT("이벤트특가"), | ||
LAUNCHING("런칭특가"); | ||
|
||
private final String name; | ||
|
||
BadgeType(String name) { | ||
this.name = name; | ||
} | ||
} | ||
} | ||
|
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,35 @@ | ||
package com.team10.banchan.model; | ||
|
||
import org.springframework.data.annotation.Id; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class Category { | ||
@Id | ||
private final Long id; | ||
private final String name; | ||
private final Set<Item> items; | ||
|
||
Category(Long id, String name, Set<Item> items) { | ||
this.id = id; | ||
this.name = name; | ||
this.items = items; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public Set<Item> getItems() { | ||
return items; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public static Category newCategory(String name) { | ||
return new Category(null, name, new HashSet<>()); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
BE/src/main/java/com/team10/banchan/model/DeliveryDay.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,58 @@ | ||
package com.team10.banchan.model; | ||
|
||
public class DeliveryDay { | ||
private final TheDayOfWeek theDayOfWeek; | ||
|
||
DeliveryDay(TheDayOfWeek theDayOfWeek) { | ||
this.theDayOfWeek = theDayOfWeek; | ||
} | ||
|
||
public String korean() { | ||
return theDayOfWeek.korean; | ||
} | ||
|
||
public static DeliveryDay monday() { | ||
return new DeliveryDay(TheDayOfWeek.MON); | ||
} | ||
|
||
public static DeliveryDay tuesday() { | ||
return new DeliveryDay(TheDayOfWeek.TUE); | ||
} | ||
|
||
public static DeliveryDay wednesday() { | ||
return new DeliveryDay(TheDayOfWeek.WED); | ||
} | ||
|
||
public static DeliveryDay thursday() { | ||
return new DeliveryDay(TheDayOfWeek.THU); | ||
} | ||
|
||
public static DeliveryDay friday() { | ||
return new DeliveryDay(TheDayOfWeek.FRI); | ||
} | ||
|
||
public static DeliveryDay saturday() { | ||
return new DeliveryDay(TheDayOfWeek.SAT); | ||
} | ||
|
||
public static DeliveryDay sunday() { | ||
return new DeliveryDay(TheDayOfWeek.SUN); | ||
} | ||
|
||
enum TheDayOfWeek { | ||
MON("월"), | ||
TUE("화"), | ||
WED("수"), | ||
THU("목"), | ||
FRI("금"), | ||
SAT("토"), | ||
SUN("일"); | ||
|
||
private final String korean; | ||
|
||
TheDayOfWeek(String korean) { | ||
this.korean = korean; | ||
} | ||
} | ||
} | ||
|
39 changes: 39 additions & 0 deletions
39
BE/src/main/java/com/team10/banchan/model/DeliveryType.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,39 @@ | ||
package com.team10.banchan.model; | ||
|
||
public class DeliveryType { | ||
private final DeliveryTypeEnum deliveryTypeName; | ||
|
||
DeliveryType(DeliveryTypeEnum deliveryTypeName) { | ||
this.deliveryTypeName = deliveryTypeName; | ||
} | ||
|
||
public String getName() { | ||
return deliveryTypeName.name; | ||
} | ||
|
||
public String getDetail() { | ||
return deliveryTypeName.detail; | ||
} | ||
|
||
public static DeliveryType nationwide() { | ||
return new DeliveryType(DeliveryTypeEnum.NATIONWIDE); | ||
} | ||
|
||
public static DeliveryType dawn() { | ||
return new DeliveryType(DeliveryTypeEnum.DAWN); | ||
} | ||
|
||
enum DeliveryTypeEnum { | ||
NATIONWIDE("전국택배", "전국택배 (제주 및 도서산간 불가)"), | ||
DAWN("새벽배송", "서울 경기 새벽배송"); | ||
|
||
private final String name; | ||
private final String detail; | ||
|
||
DeliveryTypeEnum(String name, String detail) { | ||
this.name = name; | ||
this.detail = detail; | ||
} | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
BE/src/main/java/com/team10/banchan/model/DetailSection.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,17 @@ | ||
package com.team10.banchan.model; | ||
|
||
public class DetailSection { | ||
private final String url; | ||
|
||
DetailSection(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public static DetailSection of(String url) { | ||
return new DetailSection(url); | ||
} | ||
} |
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,143 @@ | ||
package com.team10.banchan.model; | ||
|
||
import org.springframework.data.annotation.Id; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class Item { | ||
@Id | ||
private final Long id; | ||
private final Long section; | ||
private final Long category; | ||
|
||
private final String alt; | ||
private final String topImage; | ||
private final String title; | ||
private final String description; | ||
private final BigDecimal nPrice; | ||
private final BigDecimal sPrice; | ||
private final BigDecimal deliveryFee; | ||
private final Integer stock; | ||
|
||
private final List<DetailSection> detailSections; | ||
private final List<ThumbImage> thumbImages; | ||
private final Set<Badge> badges; | ||
private final Set<DeliveryType> deliveryTypes; | ||
private final Set<DeliveryDay> deliveryDays; | ||
|
||
Item(Long id, Long section, Long category, String alt, String topImage, String title, String description, BigDecimal nPrice, BigDecimal sPrice, BigDecimal deliveryFee, Integer stock, List<DetailSection> detailSections, List<ThumbImage> thumbImages, Set<Badge> badges, Set<DeliveryType> deliveryTypes, Set<DeliveryDay> deliveryDays) { | ||
this.id = id; | ||
this.section = section; | ||
this.category = category; | ||
this.alt = alt; | ||
this.topImage = topImage; | ||
this.title = title; | ||
this.description = description; | ||
this.nPrice = nPrice; | ||
this.sPrice = sPrice; | ||
this.deliveryFee = deliveryFee; | ||
this.stock = stock; | ||
this.detailSections = detailSections; | ||
this.thumbImages = thumbImages; | ||
this.badges = badges; | ||
this.deliveryTypes = deliveryTypes; | ||
this.deliveryDays = deliveryDays; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public Long getSection() { | ||
return section; | ||
} | ||
|
||
public Long getCategory() { | ||
return category; | ||
} | ||
|
||
public String getAlt() { | ||
return alt; | ||
} | ||
|
||
public String getTopImage() { | ||
return topImage; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public BigDecimal getNPrice() { | ||
return nPrice; | ||
} | ||
|
||
public BigDecimal getSPrice() { | ||
return sPrice; | ||
} | ||
|
||
public BigDecimal getDeliveryFee() { | ||
return deliveryFee; | ||
} | ||
|
||
public Integer getStock() { | ||
return stock; | ||
} | ||
|
||
public List<DetailSection> getDetailSections() { | ||
return detailSections; | ||
} | ||
|
||
public List<ThumbImage> getThumbImages() { | ||
return thumbImages; | ||
} | ||
|
||
public Set<Badge> getBadges() { | ||
return badges; | ||
} | ||
|
||
public Set<DeliveryType> getDeliveryTypes() { | ||
return deliveryTypes; | ||
} | ||
|
||
public Set<DeliveryDay> getDeliveryDays() { | ||
return deliveryDays; | ||
} | ||
|
||
public void addDetailSection (DetailSection detailSection) { | ||
this.detailSections.add(detailSection); | ||
} | ||
|
||
public void addThumbImage (ThumbImage thumbImage) { | ||
this.thumbImages.add(thumbImage); | ||
} | ||
|
||
public void addBadge(Badge badge) { | ||
this.badges.add(badge); | ||
} | ||
|
||
public void addDeliveryType(DeliveryType deliveryType) { | ||
this.deliveryTypes.add(deliveryType); | ||
} | ||
|
||
public void addDeliveryDay(DeliveryDay deliveryDay) { | ||
this.deliveryDays.add(deliveryDay); | ||
} | ||
|
||
public static Item newItem(Long section, Long category, | ||
String alt, String topImage, String title, String description, | ||
BigDecimal nPrice, BigDecimal sPrice, BigDecimal deliveryFee, Integer stock) { | ||
return new Item(null, section, category, | ||
alt, topImage, title, description, | ||
nPrice, sPrice, deliveryFee, stock, | ||
new ArrayList<>(), new ArrayList<>(), new HashSet<>(), new HashSet<>(), new HashSet<>()); | ||
} | ||
} |
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,35 @@ | ||
package com.team10.banchan.model; | ||
|
||
import org.springframework.data.annotation.Id; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class Section { | ||
@Id | ||
private final Long id; | ||
private final String name; | ||
private final Set<Item> items; | ||
|
||
Section(Long id, String name, Set<Item> items) { | ||
this.id = id; | ||
this.name = name; | ||
this.items = items; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public Set<Item> getItems() { | ||
return items; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public static Section newSection(String name) { | ||
return new Section(null, name, new HashSet<>()); | ||
} | ||
} |
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,17 @@ | ||
package com.team10.banchan.model; | ||
|
||
public class ThumbImage { | ||
private final String url; | ||
|
||
ThumbImage(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public static ThumbImage of(String url) { | ||
return new ThumbImage(url); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
BE/src/main/java/com/team10/banchan/repository/CategoryRepository.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,11 @@ | ||
package com.team10.banchan.repository; | ||
|
||
import com.team10.banchan.model.Category; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface CategoryRepository extends CrudRepository<Category, Long> { | ||
@Override | ||
List<Category> findAll(); | ||
} |
Oops, something went wrong.