-
Notifications
You must be signed in to change notification settings - Fork 0
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 #12 from Team-Shaka/feat/5
✨ Feat: 엔티티 매핑
- Loading branch information
Showing
16 changed files
with
394 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/treehouse/server/global/entity/Invitation/Invitation.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,35 @@ | ||
package treehouse.server.global.entity.Invitation; | ||
|
||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import treehouse.server.global.entity.common.BaseDateTimeEntity; | ||
import treehouse.server.global.entity.member.Member; | ||
import treehouse.server.global.entity.treeHouse.TreeHouse; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Invitation extends BaseDateTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String phone; | ||
|
||
@Setter | ||
private InvitationStatus status; | ||
|
||
private LocalDateTime expiredAt; //초대장 만료일자 | ||
|
||
@JoinColumn(name = "senderId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member sender; | ||
@JoinColumn(name = "treeId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private TreeHouse treeHouse; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/treehouse/server/global/entity/Invitation/InvitationStatus.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,6 @@ | ||
package treehouse.server.global.entity.Invitation; | ||
|
||
public enum InvitationStatus { | ||
PENDING, ACCEPTED, REJECTED | ||
//초대장의 상태 - 대기중, 수락, 거절 | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/treehouse/server/global/entity/User/User.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,53 @@ | ||
package treehouse.server.global.entity.User; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import treehouse.server.global.entity.common.BaseDateTimeEntity; | ||
import treehouse.server.global.entity.member.Member; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Table(name = "user") | ||
public class User extends BaseDateTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(unique = true) | ||
private String phone; | ||
private String name; //고유 문자열 아이디(인스타그램 st.) | ||
private String bio; | ||
|
||
private String profileImageUrl; //프로필 이미지 | ||
|
||
private UserStatus status; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private UserRole role; | ||
|
||
// 활동량 및 초대장 개수 트리별로 적용되는 것 맞는지 확인하기 | ||
@Builder.Default | ||
private Double activeRate = 0.0; //활동량 | ||
@Builder.Default | ||
private Integer invitationCount = 3; //남아있는 초대장의 개수 | ||
|
||
// 탈퇴일자 필요한지 확인하기 | ||
// 특정 트리의 탈퇴한 멤버를 Member Table 에 그대로 쌓을건지? | ||
// db의 Member Table에 userId 필드 값은 그대로 두는지 or -1 등으로 갱신하는지 | ||
// - 만약 특정 User가 특정 Tree에 들어간 적이 있는지 알아야 한다면 | ||
private LocalDateTime inactivatedAt; //탈퇴일자 | ||
|
||
|
||
@OneToMany(mappedBy = "user") | ||
private List<Member> memberList; | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/treehouse/server/global/entity/User/UserRole.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,16 @@ | ||
package treehouse.server.global.entity.User; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum UserRole { | ||
ROLE_GUEST("게스트"), | ||
ROLE_USER("회원"), | ||
ROLE_ADMIN("관리자"), | ||
ADMIN("lagacy 관리자"), | ||
USER("lagacy 회원"); | ||
|
||
private final String description; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/treehouse/server/global/entity/User/UserStatus.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,5 @@ | ||
package treehouse.server.global.entity.User; | ||
|
||
public enum UserStatus { | ||
ACTIVE, INACTIVE, WITHDRAWAL | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/treehouse/server/global/entity/comment/Comment.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,26 @@ | ||
package treehouse.server.global.entity.comment; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import treehouse.server.global.entity.common.BaseDateTimeEntity; | ||
import treehouse.server.global.entity.feed.Feed; | ||
import treehouse.server.global.entity.member.Member; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Comment extends BaseDateTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@JoinColumn(name = "writerId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member writer; | ||
|
||
@JoinColumn(name = "feedId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Feed feed; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/treehouse/server/global/entity/common/BaseDateTimeEntity.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,25 @@ | ||
package treehouse.server.global.entity.common; | ||
|
||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.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; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@EntityListeners(AuditingEntityListener.class) | ||
@MappedSuperclass | ||
@Getter | ||
public abstract class BaseDateTimeEntity { | ||
|
||
@Column(updatable = false) | ||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@LastModifiedDate | ||
private LocalDateTime updatedAt; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/treehouse/server/global/entity/feed/Feed.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 treehouse.server.global.entity.feed; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import treehouse.server.global.entity.comment.Comment; | ||
import treehouse.server.global.entity.common.BaseDateTimeEntity; | ||
import treehouse.server.global.entity.member.Member; | ||
import treehouse.server.global.entity.treeHouse.TreeHouse; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Feed extends BaseDateTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@JoinColumn(name = "writerId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member writer; | ||
|
||
@JoinColumn(name = "userId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private TreeHouse treeHouse; | ||
|
||
private String content; | ||
|
||
@OneToMany(mappedBy = "feed") | ||
private List<Comment> commentList; | ||
|
||
@OneToMany(mappedBy = "feed") | ||
private List<FeedImage> feedImageList; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/treehouse/server/global/entity/feed/FeedImage.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,23 @@ | ||
package treehouse.server.global.entity.feed; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import treehouse.server.global.entity.common.BaseDateTimeEntity; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class FeedImage extends BaseDateTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String imageUrl; | ||
|
||
@JoinColumn(name = "feedId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Feed feed; | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/treehouse/server/global/entity/member/Member.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,55 @@ | ||
package treehouse.server.global.entity.member; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import treehouse.server.global.entity.Invitation.Invitation; | ||
import treehouse.server.global.entity.User.User; | ||
import treehouse.server.global.entity.comment.Comment; | ||
import treehouse.server.global.entity.common.BaseDateTimeEntity; | ||
import treehouse.server.global.entity.notification.Notification; | ||
import treehouse.server.global.entity.reaction.Reaction; | ||
import treehouse.server.global.entity.treeHouse.TreeHouse; | ||
|
||
import java.util.List; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Table(name = "member") | ||
public class Member extends BaseDateTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
private String name; //트리에서 사용할 닉네임 | ||
|
||
private String bio; //자기소개 | ||
|
||
private String profileImageUrl; //프로필 이미지(트리 별로 상이) | ||
|
||
@JoinColumn(name = "userId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private User user; | ||
|
||
@JoinColumn(name = "treeId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private TreeHouse treeHouse; | ||
|
||
@OneToMany(mappedBy = "receiver") | ||
List<Notification> notificationList; | ||
|
||
@OneToMany(mappedBy = "writer") | ||
List<Comment> commentList; | ||
|
||
@OneToMany(mappedBy = "sender") | ||
List<Invitation> invitationList; | ||
|
||
@OneToMany(mappedBy = "member") | ||
List<Reaction> reactionList; | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/treehouse/server/global/entity/notification/Notification.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 treehouse.server.global.entity.notification; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import treehouse.server.global.entity.common.BaseDateTimeEntity; | ||
import treehouse.server.global.entity.member.Member; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Notification extends BaseDateTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String title; | ||
|
||
private String body; | ||
private boolean readStatus; | ||
|
||
@JoinColumn(name = "senderId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member sender; | ||
|
||
@JoinColumn(name = "receiverId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member receiver; | ||
|
||
private Long targetId; | ||
private LocalDateTime receivedTime; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/treehouse/server/global/entity/notification/NotificationType.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,5 @@ | ||
package treehouse.server.global.entity.notification; | ||
|
||
public enum NotificationType { | ||
INVITATION, COMMENT, REACTION | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/treehouse/server/global/entity/reaction/Reaction.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,30 @@ | ||
package treehouse.server.global.entity.reaction; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import treehouse.server.global.entity.common.BaseDateTimeEntity; | ||
import treehouse.server.global.entity.member.Member; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Reaction extends BaseDateTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@JoinColumn(name = "memberId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member member; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ReactionType type; // 예: LIKE, DISLIKE 등 | ||
|
||
private Long targetId; // 반응 대상의 ID | ||
|
||
@Enumerated(EnumType.STRING) | ||
private TargetType targetType; | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/treehouse/server/global/entity/reaction/ReactionType.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,5 @@ | ||
package treehouse.server.global.entity.reaction; | ||
|
||
public enum ReactionType { | ||
LIKE, DISLIKE, SAD, ANGRY | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/treehouse/server/global/entity/reaction/TargetType.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,5 @@ | ||
package treehouse.server.global.entity.reaction; | ||
|
||
public enum TargetType { | ||
POST, COMMENT, REPLY | ||
} |
Oops, something went wrong.