-
Notifications
You must be signed in to change notification settings - Fork 3
[#23] create Entity, schema about Item & Order #24
base: feature/19
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package me.jjeda.mall.items.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
|
||
@Entity | ||
@Getter @Setter | ||
public class Category { | ||
|
||
@Id @GeneratedValue | ||
@Column(name = "category_id") | ||
private Long id; | ||
|
||
private String name; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package me.jjeda.mall.items.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.OneToMany; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter @Setter | ||
public class Item { | ||
|
||
@Id | ||
@GeneratedValue | ||
@Column(name = "item_id") | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private int price; | ||
|
||
private int stockQuantity; | ||
|
||
@OneToMany(mappedBy = "item") | ||
private List<ItemCategory> itemCategories = new ArrayList<>(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package me.jjeda.mall.items.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
|
||
@Entity | ||
@Getter @Setter | ||
public class ItemCategory { | ||
|
||
@Id @GeneratedValue | ||
@Column(name = "item_category_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "item_id") | ||
private Item item; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "category_id") | ||
private Category category; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package me.jjeda.mall.orders.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import me.jjeda.mall.common.model.Address; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embedded; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.OneToOne; | ||
|
||
@Entity | ||
@Getter @Setter | ||
public class Delivery { | ||
|
||
@Id | ||
@GeneratedValue | ||
@Column(name = "delivery_id") | ||
private Long id; | ||
|
||
@OneToOne(mappedBy = "delivery") | ||
private Order order; | ||
|
||
@Embedded | ||
private Address address; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private DeliveryStatus status; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package me.jjeda.mall.orders.domain; | ||
|
||
/** | ||
* READY : 배송 준비 | ||
* DELIVERY : 배송 중 | ||
* COMP : 배송 완료 | ||
*/ | ||
public enum DeliveryStatus { | ||
READY, DELIVERY, COMP | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package me.jjeda.mall.orders.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import me.jjeda.mall.accounts.domain.Account; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.Index; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.OneToMany; | ||
import javax.persistence.OneToOne; | ||
import javax.persistence.Table; | ||
import javax.validation.constraints.NotNull; | ||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter @Setter | ||
@Table(name = "orders", indexes = {@Index(columnList = "orderAt")} ) | ||
public class Order { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아직 안만드신것이겠지만 결제정보도 있으면 좋을 것 같네요~ |
||
|
||
@Id @GeneratedValue | ||
@Column(name = "order_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 우선 한 구매자가 여러개의 주문을 하는 상황이 있기 때문에
위와 같은 이유 입니다! |
||
@JoinColumn(name = "account_id") | ||
private Account account; | ||
|
||
/** | ||
* 주로 access 하는 Order를 연관관계의 주인으로 설정 | ||
*/ | ||
@OneToOne | ||
@JoinColumn(name = "delivery_id") | ||
private Delivery delivery; | ||
|
||
@OneToMany(mappedBy = "order") | ||
@NotNull | ||
private List<OrderItem> orderItems; | ||
|
||
private LocalDateTime orderAt; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private OrderStatus status; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package me.jjeda.mall.orders.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import me.jjeda.mall.items.domain.Item; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
|
||
@Entity | ||
@Getter @Setter | ||
public class OrderItem { | ||
|
||
@Id @GeneratedValue | ||
@Column(name = "order_item_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "item_id") | ||
private Item item; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "order_id") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 보통 Order에서 OrderItem을 join해서 가져올텐데 여기에 명시해주지 않아도 되지 않을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분도 위에와 같은 이유입니다!
를 참고 하였습니다! |
||
private Order order; | ||
|
||
private int orderPrice; | ||
|
||
private int count; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package me.jjeda.mall.orders.domain; | ||
|
||
/** | ||
* ORDER : 주문 | ||
* CANCEL : 주문취소 | ||
*/ | ||
public enum OrderStatus { | ||
ORDER, CANCEL | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
create table account ( | ||
id bigint not null, | ||
account_id bigint not null, | ||
city varchar(255), | ||
street varchar(255), | ||
zip_code varchar(255), | ||
|
@@ -10,8 +10,64 @@ create table account ( | |
password varchar(255), | ||
phone varchar(255), | ||
status varchar(255), | ||
primary key (id)); | ||
primary key (account_id)); | ||
|
||
create table account_account_role ( | ||
account_id bigint not null, | ||
account_role varchar(255)); | ||
account_role varchar(255), | ||
foreign key (account_account_id) references account (account_id)); | ||
|
||
create table category ( | ||
category_id bigint not null, | ||
name varchar(255), | ||
primary key (category_id)); | ||
|
||
create table item ( | ||
item_id bigint not null, | ||
name varchar(255), | ||
price integer not null, | ||
stock_quantity integer not null, | ||
primary key (item_id)); | ||
|
||
create table item_category ( | ||
item_category_id bigint not null, | ||
category_id bigint, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 들여쓰기가 조금씩 차이가 있는데 이를 맞춰주는것이 컨벤션상 좋을 것 같습니다~ |
||
item_id bigint, | ||
primary key (item_category_id), | ||
foreign key (category_id) references category (category_id), | ||
foreign key (item_id) references item (item_id)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
create table orders ( | ||
order_id bigint not null, | ||
order_at datetime not null, | ||
status varchar(255), | ||
account_id bigint, | ||
delivery_id bigint, | ||
index (order_at), | ||
primary key (order_id), | ||
foreign key (account_id) references account (account_id) | ||
foreign key (delivery_id) references delivery (delivery_id)); | ||
|
||
create table order_item ( | ||
order_item_id bigint not null, | ||
count integer not null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
order_price integer not null, | ||
item_id bigint, | ||
order_id bigint, | ||
primary key (order_item_id), | ||
foreign key (item_id) references item (item_id), | ||
foreign key (order_id) references orders (order_id)); | ||
|
||
create table delivery ( | ||
delivery_id bigint not null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 담당 배달원이 누구인지도 명시해줘야할것같습니다~ |
||
city varchar(255), | ||
street varchar(255), | ||
zip_code varchar(255), | ||
status varchar(255), | ||
primary key (delivery_id)); | ||
|
||
|
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍