Skip to content

Commit

Permalink
Merge pull request #13 from a-romantic-cat/feat/10
Browse files Browse the repository at this point in the history
✨ entity 생성
  • Loading branch information
yerimm99 authored Jan 18, 2024
2 parents 6f1b7e7 + 4e536bb commit a3f24b6
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
21 changes: 21 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -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;
}
29 changes: 29 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/Friend.java
Original file line number Diff line number Diff line change
@@ -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;
}
24 changes: 24 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/ItemBox.java
Original file line number Diff line number Diff line change
@@ -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;

}
39 changes: 39 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/Member.java
Original file line number Diff line number Diff line change
@@ -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<MemberMission> memberMissions = new ArrayList<>();

@OneToMany(mappedBy = "member", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<Friend> friends = new ArrayList<>();

@OneToMany(mappedBy = "member", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<NangmanLetter> nangmanLetters = new ArrayList<>();

@OneToMany(mappedBy = "member", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<NangmanReply> nangmanReplies = new ArrayList<>();
}
32 changes: 32 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/MemberMission.java
Original file line number Diff line number Diff line change
@@ -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;

}
30 changes: 30 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/Mission.java
Original file line number Diff line number Diff line change
@@ -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<MemberMission> memberMissions = new ArrayList<>();
}
43 changes: 43 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/NangmanLetter.java
Original file line number Diff line number Diff line change
@@ -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;
}
32 changes: 32 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/NangmanReply.java
Original file line number Diff line number Diff line change
@@ -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;
}
32 changes: 32 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/Reward.java
Original file line number Diff line number Diff line change
@@ -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;

}
4 changes: 2 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,4 +16,4 @@ spring:
use_sql_comments: true
hbm2ddl:
auto: update
default_batch_fetch_size: 1000
default_batch_fetch_size: 1000

0 comments on commit a3f24b6

Please sign in to comment.