-
Notifications
You must be signed in to change notification settings - Fork 1
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 #22 from mjuCapstone/feat/21-Entity-개발
feat : 추가 구현 ERD 개발합니다.
- Loading branch information
Showing
6 changed files
with
186 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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/mju/capstone/food/history/entity/History.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,42 @@ | ||
package com.mju.capstone.food.history.entity; | ||
|
||
import com.mju.capstone.global.baseEntity.BaseTimeEntity; | ||
import com.mju.capstone.member.entity.Member; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@Entity | ||
public class History extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
private int tot_kcal; | ||
|
||
private int tot_carbohydrate; | ||
|
||
private int tot_protein; | ||
|
||
private int tot_fat; | ||
|
||
public History(Member member, int tot_kcal, int tot_carbohydrate, int tot_protein, int tot_fat) { | ||
this.member = member; | ||
this.tot_kcal = tot_kcal; | ||
this.tot_carbohydrate = tot_carbohydrate; | ||
this.tot_protein = tot_protein; | ||
this.tot_fat = tot_fat; | ||
} | ||
} |
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,45 @@ | ||
package com.mju.capstone.food.item.entity; | ||
|
||
import com.mju.capstone.food.history.entity.History; | ||
import com.mju.capstone.global.baseEntity.BaseTimeEntity; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor | ||
@Getter | ||
public class Item extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "history_id") | ||
private History history; | ||
|
||
private String name; | ||
|
||
private int kcal; | ||
|
||
private int carbohydrate; | ||
|
||
private int protein; | ||
|
||
private int fat; | ||
|
||
public Item(History history, String name, int kcal, int carbohydrate, int protein, int fat) { | ||
this.history = history; | ||
this.name = name; | ||
this.kcal = kcal; | ||
this.carbohydrate = carbohydrate; | ||
this.protein = protein; | ||
this.fat = fat; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/mju/capstone/global/baseEntity/BaseTimeEntity.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,21 @@ | ||
package com.mju.capstone.global.baseEntity; | ||
|
||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class BaseTimeEntity { | ||
|
||
@CreatedDate | ||
private LocalDateTime localDateTime; | ||
|
||
@LastModifiedDate | ||
private LocalDateTime modifiedDate; | ||
} |
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,38 @@ | ||
package com.mju.capstone.menu.entity; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class Menu { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private String food_id; | ||
|
||
private String name; | ||
|
||
private int kcal; | ||
|
||
private int carbohydrate; | ||
|
||
private int protein; | ||
|
||
private int fat; | ||
|
||
@Builder | ||
public Menu(String name, int kcal, int carbohydrate, int protein, int fat) { | ||
this.name = name; | ||
this.kcal = kcal; | ||
this.carbohydrate = carbohydrate; | ||
this.protein = protein; | ||
this.fat = fat; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/mju/capstone/preference/entity/Preference.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,38 @@ | ||
package com.mju.capstone.preference.entity; | ||
|
||
import com.mju.capstone.global.baseEntity.BaseTimeEntity; | ||
import com.mju.capstone.member.entity.Member; | ||
import com.mju.capstone.menu.entity.Menu; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class Preference extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "menu_id") | ||
private Menu menu; | ||
|
||
@Builder | ||
public Preference(Member member, Menu menu) { | ||
this.member = member; | ||
this.menu = menu; | ||
} | ||
} |