Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/create entity #12

Merged
merged 2 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,20 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-hateoas'

// MySQL spatial
implementation 'org.hibernate:hibernate-core:6.1.7.Final'
implementation 'org.hibernate:hibernate-spatial:6.1.7.Final'

// TSID
implementation 'io.hypersistence:hypersistence-utils-hibernate-63:3.7.0'
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/sooum/core/CoreApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing
public class CoreApplication {

public static void main(String[] args) {
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/com/sooum/core/domain/block/entity/Block.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.sooum.core.domain.block.entity;

import com.sooum.core.domain.common.entity.BaseEntity;
import com.sooum.core.domain.member.entity.Member;
import io.hypersistence.utils.hibernate.id.Tsid;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Block extends BaseEntity {
@Id @Tsid
private Long pk;

@NotNull
@JoinColumn(name = "FROM_MEMBER")
@ManyToOne(fetch = FetchType.LAZY)
private Member fromMember;

@NotNull
@JoinColumn(name = "TO_MEMBER")
@ManyToOne(fetch = FetchType.LAZY)
private Member toMember;

@Builder
public Block(Member fromMember, Member toMember) {
this.fromMember = fromMember;
this.toMember = toMember;
}
}
73 changes: 73 additions & 0 deletions src/main/java/com/sooum/core/domain/card/entity/CommentCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.sooum.core.domain.card.entity;

import com.sooum.core.domain.card.font.Font;
import com.sooum.core.domain.card.fontsize.FontSize;
import com.sooum.core.domain.card.imgtype.ImgType;
import com.sooum.core.domain.common.entity.BaseEntity;
import com.sooum.core.domain.member.entity.Member;
import io.hypersistence.utils.hibernate.id.Tsid;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.locationtech.jts.geom.Point;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class CommentCard extends BaseEntity {
@Id @Tsid
private Long pk;

@NotNull
@Column(name = "CONTENT", columnDefinition = "TEXT")
private String content;

@NotNull
@Enumerated(value = EnumType.STRING)
private FontSize fontSize;
@NotNull
@Enumerated(value = EnumType.STRING)
private Font font;

@Column(name = "LOCATION", columnDefinition = "GEOMETRY")
private Point location;

@NotNull
@Enumerated(value = EnumType.STRING)
private ImgType imgType;
@NotNull
@Column(name = "IMG_NAME")
private String imgName;

@Column(name = "IS_PUBLIC")
private boolean isPublic;

@Column(name = "IS_STORY")
private boolean isStory;

@NotNull
@JoinColumn(name = "WRITER")
@ManyToOne(fetch = FetchType.LAZY)
private Member writer;

@NotNull
@JoinColumn(name = "PARENT_CARD")
@ManyToOne(fetch = FetchType.LAZY)
private FeedCard parentCard;

public CommentCard(String content, FontSize fontSize, Font font, Point location, ImgType imgType, String imgName, boolean isPublic, boolean isStory, Member writer, FeedCard parentCard) {
this.content = content;
this.fontSize = fontSize;
this.font = font;
this.location = location;
this.imgType = imgType;
this.imgName = imgName;
this.isPublic = isPublic;
this.isStory = isStory;
this.writer = writer;
this.parentCard = parentCard;
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/sooum/core/domain/card/entity/CommentLike.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.sooum.core.domain.card.entity;

import com.sooum.core.domain.common.entity.BaseEntity;
import com.sooum.core.domain.member.entity.Member;
import io.hypersistence.utils.hibernate.id.Tsid;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class CommentLike extends BaseEntity {
@Id @Tsid
private Long pk;

@NotNull
@JoinColumn(name = "TARGET_CARD")
@ManyToOne(fetch = FetchType.LAZY)
private CommentCard targetCard;

@NotNull
@JoinColumn(name = "LIKED_MEMBER")
@ManyToOne(fetch = FetchType.LAZY)
private Member likedMember;

@Builder
public CommentLike(CommentCard targetCard, Member likedMember) {
this.targetCard = targetCard;
this.likedMember = likedMember;
}
}
68 changes: 68 additions & 0 deletions src/main/java/com/sooum/core/domain/card/entity/FeedCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.sooum.core.domain.card.entity;

import com.sooum.core.domain.card.font.Font;
import com.sooum.core.domain.card.fontsize.FontSize;
import com.sooum.core.domain.card.imgtype.ImgType;
import com.sooum.core.domain.common.entity.BaseEntity;
import com.sooum.core.domain.member.entity.Member;
import io.hypersistence.utils.hibernate.id.Tsid;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.locationtech.jts.geom.Point;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class FeedCard extends BaseEntity {
@Id @Tsid
private Long pk;

@NotNull
@Column(name = "CONTENT", columnDefinition = "TEXT")
private String content;

@NotNull
@Enumerated(value = EnumType.STRING)
private FontSize fontSize;
@NotNull
@Enumerated(value = EnumType.STRING)
private Font font;

@Column(name = "LOCATION", columnDefinition = "GEOMETRY")
private Point location;

@NotNull
@Enumerated(value = EnumType.STRING)
private ImgType imgType;
@NotNull
@Column(name = "IMG_NAME")
private String imgName;

@Column(name = "IS_PUBLIC")
private boolean isPublic;

@Column(name = "IS_STORY")
private boolean isStory;

@NotNull
@JoinColumn(name = "WRITER")
@ManyToOne(fetch = FetchType.LAZY)
private Member writer;

@Builder
public FeedCard(String content, FontSize fontSize, Font font, Point location, ImgType imgType, String imgName, boolean isPublic, boolean isStory, Member writer) {
this.content = content;
this.fontSize = fontSize;
this.font = font;
this.location = location;
this.imgType = imgType;
this.imgName = imgName;
this.isPublic = isPublic;
this.isStory = isStory;
this.writer = writer;
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/sooum/core/domain/card/entity/FeedLike.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.sooum.core.domain.card.entity;

import com.sooum.core.domain.common.entity.BaseEntity;
import com.sooum.core.domain.member.entity.Member;
import io.hypersistence.utils.hibernate.id.Tsid;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class FeedLike extends BaseEntity {
@Id @Tsid
private Long pk;

@NotNull
@JoinColumn(name = "TARGET_CARD")
@ManyToOne(fetch = FetchType.LAZY)
private FeedCard targetCard;

@NotNull
@JoinColumn(name = "LIKED_MEMBER")
@ManyToOne(fetch = FetchType.LAZY)
private Member likedMember;

@Builder
public FeedLike(FeedCard targetCard, Member likedMember) {
this.targetCard = targetCard;
this.likedMember = likedMember;
}
}
28 changes: 28 additions & 0 deletions src/main/java/com/sooum/core/domain/card/entity/PopularCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.sooum.core.domain.card.entity;

import com.sooum.core.domain.common.entity.BaseEntity;
import io.hypersistence.utils.hibernate.id.Tsid;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class PopularCard extends BaseEntity {
@Id @Tsid
private Long pk;

@NotNull
@JoinColumn(name = "POPULAR_CARD")
@OneToOne(fetch = FetchType.LAZY)
private FeedCard popularCard;

@Builder
public PopularCard(FeedCard popularCard) {
this.popularCard = popularCard;
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/sooum/core/domain/card/font/Font.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.sooum.core.domain.card.font;

public enum Font {
DEFAULT, CUSTOM
}
16 changes: 16 additions & 0 deletions src/main/java/com/sooum/core/domain/card/fontsize/FontSize.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.sooum.core.domain.card.fontsize;

public enum FontSize {
BIG(300),
SMALL(200);

private final int size;

public int getSize() {
return size;
}

FontSize(int size) {
this.size = size;
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/sooum/core/domain/card/imgtype/ImgType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.sooum.core.domain.card.imgtype;

public enum ImgType {
DEFAULT, USER
}
19 changes: 19 additions & 0 deletions src/main/java/com/sooum/core/domain/common/entity/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.sooum.core.domain.common.entity;

import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Getter
@Setter
@MappedSuperclass
@EntityListeners(value = AuditingEntityListener.class)
public abstract class BaseEntity {
@CreatedDate
private LocalDateTime createdTime;
}
35 changes: 35 additions & 0 deletions src/main/java/com/sooum/core/domain/follow/entity/Follow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.sooum.core.domain.follow.entity;

import com.sooum.core.domain.common.entity.BaseEntity;
import com.sooum.core.domain.member.entity.Member;
import io.hypersistence.utils.hibernate.id.Tsid;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Follow extends BaseEntity {
@Id @Tsid
private Long pk;

@NotNull
@JoinColumn(name = "FROM_MEMBER")
@ManyToOne(fetch = FetchType.LAZY)
private Member fromMember;

@NotNull
@JoinColumn(name = "TO_MEMBER")
@ManyToOne(fetch = FetchType.LAZY)
private Member toMember;

@Builder
public Follow(Member fromMember, Member toMember) {
this.fromMember = fromMember;
this.toMember = toMember;
}
}
Loading