-
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 #14 from 2024-TEAM-05/feature/entity-definition
Entity 정의
- Loading branch information
Showing
10 changed files
with
203 additions
and
3 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
28 changes: 28 additions & 0 deletions
28
src/main/java/team05/integrated_feed_backend/common/BaseEntity.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,28 @@ | ||
package team05.integrated_feed_backend.common; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
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; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public abstract class BaseEntity { | ||
@Column(nullable = false, updatable = false) | ||
@CreatedDate | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") | ||
private LocalDateTime createdAt; | ||
|
||
@Column(nullable = false) | ||
@LastModifiedDate | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") | ||
private LocalDateTime updatedAt; | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/team05/integrated_feed_backend/common/enums/SocialMediaType.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,8 @@ | ||
package team05.integrated_feed_backend.common.enums; | ||
|
||
public enum SocialMediaType { | ||
INSTAGRAM, | ||
THREADS, | ||
FACEBOOK, | ||
TWITTER, | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/team05/integrated_feed_backend/core/config/JpaConfig.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,10 @@ | ||
package team05.integrated_feed_backend.core.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
||
@Configuration | ||
@EnableJpaAuditing | ||
public class JpaConfig { | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/team05/integrated_feed_backend/module/auth/entity/VerificationCode.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,29 @@ | ||
package team05.integrated_feed_backend.module.auth.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import team05.integrated_feed_backend.common.BaseEntity; | ||
import team05.integrated_feed_backend.module.user.entity.Member; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Builder | ||
public class VerificationCode extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long verificationCodeId; | ||
|
||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id", nullable = false) | ||
private Member member; | ||
|
||
@Column(nullable = false) | ||
private String code; | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime expiredAt; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/team05/integrated_feed_backend/module/post/entity/Hashtag.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,28 @@ | ||
package team05.integrated_feed_backend.module.post.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import team05.integrated_feed_backend.common.BaseEntity; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Builder | ||
public class Hashtag extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long hashtagId; | ||
|
||
@Column(nullable = false, unique = true) | ||
private String hashtag; | ||
|
||
@OneToMany(mappedBy = "hashtag", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<PostHashtag> postHashtags = new ArrayList<>(); | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/team05/integrated_feed_backend/module/post/entity/Post.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,47 @@ | ||
package team05.integrated_feed_backend.module.post.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import team05.integrated_feed_backend.common.enums.SocialMediaType; | ||
import team05.integrated_feed_backend.common.BaseEntity; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Builder | ||
public class Post extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long postId; | ||
|
||
@Column(nullable = false) | ||
private String title; | ||
|
||
@Column(nullable = false, columnDefinition = "TEXT") | ||
private String content; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
private SocialMediaType type; | ||
|
||
@Column(nullable = false) | ||
private Long viewCount; | ||
|
||
@Column(nullable = false) | ||
private Long likeCount; | ||
|
||
@Column(nullable = false) | ||
private Long shareCount; | ||
|
||
@OneToMany(mappedBy = "post", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<PostHashtag> postHashtags = new ArrayList<>(); | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/team05/integrated_feed_backend/module/post/entity/PostHashtag.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,24 @@ | ||
package team05.integrated_feed_backend.module.post.entity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import team05.integrated_feed_backend.common.BaseEntity; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Builder | ||
public class PostHashtag extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "post_hashtag_id") | ||
private Long postHashtagId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id", nullable = false) | ||
private Post post; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "hashtag_id", nullable = false) | ||
private Hashtag hashtag; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/team05/integrated_feed_backend/module/user/entity/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,28 @@ | ||
package team05.integrated_feed_backend.module.user.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import team05.integrated_feed_backend.common.BaseEntity; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Builder | ||
public class Member extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long memberId; | ||
|
||
@Column(nullable = false, unique = true) | ||
private String account; | ||
|
||
@Column(nullable = false) | ||
private String password; | ||
|
||
@Column(nullable = false, unique = true) | ||
private String email; | ||
|
||
@Column(nullable = false) | ||
private String status; | ||
} |