diff --git a/src/main/java/aromanticcat/umcproject/UmcProjectApplication.java b/src/main/java/aromanticcat/umcproject/UmcProjectApplication.java index 0882922..7cf16b1 100644 --- a/src/main/java/aromanticcat/umcproject/UmcProjectApplication.java +++ b/src/main/java/aromanticcat/umcproject/UmcProjectApplication.java @@ -2,12 +2,14 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +@EnableJpaAuditing @SpringBootApplication public class UmcProjectApplication { - public static void main(String[] args) { - SpringApplication.run(UmcProjectApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(UmcProjectApplication.class, args); + } } diff --git a/src/main/java/aromanticcat/umcproject/entity/BaseEntity.java b/src/main/java/aromanticcat/umcproject/entity/BaseEntity.java new file mode 100644 index 0000000..93ab297 --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/BaseEntity.java @@ -0,0 +1,21 @@ +package aromanticcat.umcproject.entity; + +import java.time.LocalDateTime; +import javax.persistence.EntityListeners; +import javax.persistence.MappedSuperclass; +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +@Getter +public abstract class BaseEntity { + + @CreatedDate + private LocalDateTime createdAt; + + @LastModifiedDate + private LocalDateTime updatedAt; +} diff --git a/src/main/java/aromanticcat/umcproject/entity/Friend.java b/src/main/java/aromanticcat/umcproject/entity/Friend.java new file mode 100644 index 0000000..82831e7 --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/Friend.java @@ -0,0 +1,29 @@ +package aromanticcat.umcproject.entity; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import lombok.Getter; + +@Entity +@Getter +public class Friend extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @JoinColumn(name = "to_user_id") + @ManyToOne(fetch = FetchType.LAZY) + private Member member; + + private Long from_user_id; + + private boolean are_we_friend; + + private int times; +} diff --git a/src/main/java/aromanticcat/umcproject/entity/ItemBox.java b/src/main/java/aromanticcat/umcproject/entity/ItemBox.java new file mode 100644 index 0000000..7c2f188 --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/ItemBox.java @@ -0,0 +1,24 @@ +package aromanticcat.umcproject.entity; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import lombok.Getter; + +@Entity +@Getter +public class ItemBox extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @JoinColumn(name = "member_id") + @OneToOne(fetch = FetchType.LAZY) + private Member member; + +} diff --git a/src/main/java/aromanticcat/umcproject/entity/Member.java b/src/main/java/aromanticcat/umcproject/entity/Member.java new file mode 100644 index 0000000..30dba2d --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/Member.java @@ -0,0 +1,39 @@ +package aromanticcat.umcproject.entity; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import lombok.Getter; + +@Entity +@Getter +public class Member extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String nickname; + + private String email; + + private int coin; + + @OneToMany(mappedBy = "member", fetch = FetchType.LAZY, cascade = CascadeType.ALL) + private List memberMissions = new ArrayList<>(); + + @OneToMany(mappedBy = "member", fetch = FetchType.LAZY, cascade = CascadeType.ALL) + private List friends = new ArrayList<>(); + + @OneToMany(mappedBy = "member", fetch = FetchType.LAZY, cascade = CascadeType.ALL) + private List nangmanLetters = new ArrayList<>(); + + @OneToMany(mappedBy = "member", fetch = FetchType.LAZY, cascade = CascadeType.ALL) + private List nangmanReplies = new ArrayList<>(); +} diff --git a/src/main/java/aromanticcat/umcproject/entity/MemberMission.java b/src/main/java/aromanticcat/umcproject/entity/MemberMission.java new file mode 100644 index 0000000..afff93d --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/MemberMission.java @@ -0,0 +1,32 @@ +package aromanticcat.umcproject.entity; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import lombok.Getter; + +@Entity +@Getter +public class MemberMission extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private int count; + + private boolean status; + + @JoinColumn(name = "member_id") + @ManyToOne(fetch = FetchType.LAZY) + private Member member; + + @JoinColumn(name = "mission_id") + @ManyToOne(fetch = FetchType.LAZY) + private Mission mission; + +} diff --git a/src/main/java/aromanticcat/umcproject/entity/Mission.java b/src/main/java/aromanticcat/umcproject/entity/Mission.java new file mode 100644 index 0000000..79e3089 --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/Mission.java @@ -0,0 +1,30 @@ +package aromanticcat.umcproject.entity; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import lombok.Getter; + +@Entity +@Getter +public class Mission extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String name; + + private String content; + + private String reward; + + @OneToMany(mappedBy = "mission", fetch = FetchType.LAZY, cascade = CascadeType.ALL) + private List memberMissions = new ArrayList<>(); +} diff --git a/src/main/java/aromanticcat/umcproject/entity/NangmanLetter.java b/src/main/java/aromanticcat/umcproject/entity/NangmanLetter.java new file mode 100644 index 0000000..d1cebe5 --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/NangmanLetter.java @@ -0,0 +1,43 @@ +package aromanticcat.umcproject.entity; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import lombok.Getter; + +@Entity +@Getter +public class NangmanLetter extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String sender_nickname; + + private boolean is_public; + + private String content; + + private boolean has_response; + + private int thumbs_up_cnt; + + private int heart_cnt; + + private int crying_cnt; + + private int clover_cnt; + + private int clap_cnt; + + private int star_cnt; + + @JoinColumn(name = "member_id") + @ManyToOne(fetch = FetchType.LAZY) + private Member member; +} diff --git a/src/main/java/aromanticcat/umcproject/entity/NangmanReply.java b/src/main/java/aromanticcat/umcproject/entity/NangmanReply.java new file mode 100644 index 0000000..1ad1741 --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/NangmanReply.java @@ -0,0 +1,32 @@ +package aromanticcat.umcproject.entity; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import lombok.Getter; + +@Entity +@Getter +public class NangmanReply extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String response_sender_nickname; + + private String content; + + @JoinColumn(name = "letter_id") + @OneToOne(fetch = FetchType.LAZY) + private NangmanLetter nangmanLetter; + + @JoinColumn(name = "member_id") + @ManyToOne(fetch = FetchType.LAZY) + private Member member; +} diff --git a/src/main/java/aromanticcat/umcproject/entity/Reward.java b/src/main/java/aromanticcat/umcproject/entity/Reward.java new file mode 100644 index 0000000..e9c67e4 --- /dev/null +++ b/src/main/java/aromanticcat/umcproject/entity/Reward.java @@ -0,0 +1,32 @@ +package aromanticcat.umcproject.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import lombok.Getter; + +@Entity +@Getter +public class Reward extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private int type; + + @Column(columnDefinition = "TEXT") + private String image_url; + + private String name; + + @JoinColumn(name = "mission_id") + @OneToOne(fetch = FetchType.LAZY) + private Mission mission; + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1e26b07..87c3ac4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: datasource: - url: jdbc:mysql://umc-db.clum6u48wd0b.ap-northeast-2.rds.amazonaws.com/umc + url: jdbc:mysql://umc-db.clum6u48wd0b.ap-northeast-2.rds.amazonaws.com/nangman username: root password: umcteame driver-class-name: com.mysql.cj.jdbc.Driver @@ -16,4 +16,4 @@ spring: use_sql_comments: true hbm2ddl: auto: update - default_batch_fetch_size: 1000 \ No newline at end of file + default_batch_fetch_size: 1000