Skip to content

Commit

Permalink
Merge pull request #14 from 2024-TEAM-05/feature/entity-definition
Browse files Browse the repository at this point in the history
Entity 정의
  • Loading branch information
medoeun authored Aug 23, 2024
2 parents 5a8b1eb + 7929802 commit 7f541f2
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication
public class IntegratedFeedBackendApplication {
Expand Down
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;

}
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,
}
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 {

}
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;
}
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<>();

}
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<>();

}
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;
}
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;
}

0 comments on commit 7f541f2

Please sign in to comment.