Skip to content

Commit

Permalink
Merge pull request #11 from 1223v/domain
Browse files Browse the repository at this point in the history
Feat: DB 엔티티 추가
  • Loading branch information
1223v authored Nov 13, 2023
2 parents c748fee + c3b3d61 commit 9302275
Show file tree
Hide file tree
Showing 14 changed files with 622 additions and 24 deletions.
50 changes: 50 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/Cart.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.readyvery.readyverydemo.domain;

import java.util.ArrayList;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Table(name = "CARTS")
@AllArgsConstructor
@Slf4j
public class Cart {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "cart_idx")
private Long id;

// 장바구니 유저 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_idx")
private UserInfo userInfo;

// 장바구니 가게 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "store_idx")
private Store store;

// 장바구니 장바구니 아이템 연관관계 매핑
@OneToMany(mappedBy = "cart", cascade = CascadeType.ALL)
private List<CartItem> cartItems = new ArrayList<CartItem>();

}
54 changes: 54 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/CartItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.readyvery.readyverydemo.domain;

import java.util.ArrayList;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Table(name = "CART_ITEMS")
@AllArgsConstructor
@Slf4j
public class CartItem {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "cart_item_idx")
private Long id;

// 장바구니 아이템 수량
@Column(nullable = false)
private Long count;

// 장바구니 메뉴 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "foodie_idx")
private Foodie foodie;

// 장바구니 아이템 장바구니 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cart_idx")
private Cart cart;

// 장바구니 아이템 - 장바구니 옵션 연관관계 매핑
@OneToMany(mappedBy = "cartItem", cascade = CascadeType.ALL)
private List<CartOption> cartOptions = new ArrayList<CartOption>();

}
45 changes: 45 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/CartOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.readyvery.readyverydemo.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Table(name = "CART_OPTIONS")
@AllArgsConstructor
@Slf4j
public class CartOption {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "cart_option_idx")
private Long id;

// 장바구니 옵션 - 메뉴 옵션 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "foodie_option_idx")
private FoodieOption foodieOption;

// 장바구니 옵션 - 장바구니 아이템 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cart_item_idx")
private CartItem cartItem;

// 장바구니 옵션 - 메뉴 카테고리 옵션 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "foodie_option_category_idx")
private FoodieOptionCategory foodieOptionCategory;

}
94 changes: 94 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.readyvery.readyverydemo.domain;

import static jakarta.persistence.FetchType.*;

import java.time.LocalDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Builder
@Table(name = "CEOS")
@AllArgsConstructor
@Slf4j
public class CeoInfo extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ceo_idx")
private Long id;

// 이메일
@Column(nullable = false, length = 45)
private String email;

// 닉네임
@Column(nullable = false)
private String nickName;

// 프로필 이미지
@Column(nullable = false, columnDefinition = "TEXT")
private String imageUrl;

// 연령대
@Column
private String age;

// 생일
@Column(nullable = false)
private String birth;

// 전화번호
@Column(nullable = false)
private String phone;

// 계좌번호
@Column
private String accountNumber;

// 소셜 로그인 타입
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private SocialType socialType; // KAKAO, NAVER, GOOGLE

// 소셜 로그인 타입의 식별자 값 (일반 로그인인 경우 null)
@Column(nullable = false)
private String socialId; // 로그인한 소셜 타입의 식별자 값 (일반 로그인인 경우 null)

// 유저 상태
@Column(nullable = false, columnDefinition = "BOOLEAN default true")
private boolean status;

// 리프레시 토큰
@Column(columnDefinition = "TEXT")
private String refreshToken;

// 계정 삭제 요청일
@Column
private LocalDateTime deleteDate;

// 마지막 로그인 일시
@Column
private LocalDateTime lastLoginDate;

// 사장님 가게 연관관계 매핑
@OneToOne(mappedBy = "ceoInfo", fetch = LAZY)
private Store store;

}
74 changes: 74 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/Foodie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.readyvery.readyverydemo.domain;

import java.util.ArrayList;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Table(name = "FOODIES")
@AllArgsConstructor
@Slf4j
public class Foodie {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "foodie_idx")
private Long id;

//식품 이름
@Column(nullable = false)
private String name;

//식품 가격
@Column(nullable = false)
private Long price;

//식품 이미지
@Column(nullable = false)
private String imgUrl;

//식품 매진
@Column(nullable = false, columnDefinition = "BOOLEAN default false")
private boolean soldOut;

//식품 카테고리
@Column(nullable = false)
private String category;

//메뉴 - 가게 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "store_idx")
private Store store;

//메뉴 - 식품 카테고리 연관관계 매핑
@OneToMany(mappedBy = "foodie", cascade = CascadeType.ALL)
private List<FoodieOptionCategory> foodieOptionCategory = new ArrayList<FoodieOptionCategory>();

//메뉴 - 테이크 아웃 연관관계 매핑
@OneToOne(mappedBy = "foodie", cascade = CascadeType.ALL)
private TakeOut takeOut;

//메뉴 - 장바구니 아이템 연관관계 매핑
@OneToMany(mappedBy = "foodie", cascade = CascadeType.ALL)
private List<CartItem> cartItems = new ArrayList<CartItem>();

}
53 changes: 53 additions & 0 deletions src/main/java/com/readyvery/readyverydemo/domain/FoodieOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.readyvery.readyverydemo.domain;

import java.util.ArrayList;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Table(name = "FOODIE_OPTIONS")
@AllArgsConstructor
@Slf4j
public class FoodieOption {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "foodie_option_idx")
private Long id;

//식품 옵션 이름
@Column(nullable = false)
private String name;

//식품 옵션 가격
@Column(nullable = false)
private Long price;

//식품 옵션 연관관계 매핑
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "foodie_option_category_idx")
private FoodieOptionCategory foodieOptionCategory;

// 식품 옵션 - 장바구니 옵션 연관관계 매핑
@OneToMany(mappedBy = "foodieOption", cascade = CascadeType.ALL)
private List<CartOption> cartOptions = new ArrayList<CartOption>();

}
Loading

0 comments on commit 9302275

Please sign in to comment.