Skip to content

Commit

Permalink
feat[#1] : order domain 구현 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
yujin9747 authored Jan 26, 2023
1 parent 9542fef commit 357593d
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/main/java/com/noriton/team9/domain/Order.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.noriton.team9.domain;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;

@Entity
@Getter @Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Order {

@Id @GeneratedValue
@Column(name = "order_id")
private Long id;

private int count;

private String address;

private String size;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "item_id")
private Item item;
private LocalDateTime orderDate;

private int totalPrice;

//==생성 메서드==//
public static Order createOrder(int count, String address, String size, Item item){
Order order = new Order();
order.setCount(count);
order.setAddress(address);
order.setSize(size);
order.setItem(item);
order.setOrderDate(LocalDateTime.now());
order.setTotalPrice(count * item.getPrice());
return order;
}


}

0 comments on commit 357593d

Please sign in to comment.