-
Notifications
You must be signed in to change notification settings - Fork 1
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
Hongseok week1 #3
Open
bayy1216
wants to merge
6
commits into
hongseok
Choose a base branch
from
hongseok-week1
base: hongseok
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c7384e3
[Feat]: BaseTimeEntity 추가
bayy1216 b2b4633
[Feat]: Entity 추가
bayy1216 b57cae2
[Feat]: tdd 테스트 작성
bayy1216 babf95e
[Feat]: 게시글 생성 구현
bayy1216 4808441
[Feat]: image생성 함수 리팩토링
bayy1216 0f416e5
[Feat]: fix yml
bayy1216 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
12 changes: 12 additions & 0 deletions
12
src/main/java/haedal/tdd/instagram/core/exception/ResourceNotFoundException.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,12 @@ | ||
package haedal.tdd.instagram.core.exception; | ||
|
||
public class ResourceNotFoundException extends RuntimeException { | ||
|
||
public ResourceNotFoundException(String datasource, long id) { | ||
super(datasource + "에서 ID " + id + "를 찾을 수 없습니다."); | ||
} | ||
|
||
public ResourceNotFoundException(String datasource, String id) { | ||
super(datasource + "에서 ID " + id + "를 찾을 수 없습니다."); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/haedal/tdd/instagram/core/jpa/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,9 @@ | ||
package haedal.tdd.instagram.core.jpa.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
||
@Configuration | ||
@EnableJpaAuditing | ||
public class JpaConfig { | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/haedal/tdd/instagram/entity/article/ArticleEntity.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,50 @@ | ||
package haedal.tdd.instagram.entity.article; | ||
|
||
import haedal.tdd.instagram.entity.common.BaseTimeEntity; | ||
import haedal.tdd.instagram.entity.member.MemberEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
@Table(name = "article") | ||
public class ArticleEntity extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false, length = 1000) | ||
private String content; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private MemberEntity member; | ||
|
||
@OneToMany(mappedBy = "article", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) | ||
private final List<ArticleImageEntity> articleImages = new ArrayList<>(); | ||
|
||
@Builder | ||
public ArticleEntity(String content, MemberEntity member) { | ||
this.content = content; | ||
this.member = member; | ||
} | ||
|
||
public static ArticleEntity create(String content, MemberEntity member) { | ||
return ArticleEntity.builder() | ||
.content(content) | ||
.member(member) | ||
.build(); | ||
} | ||
|
||
public void addImage(String imageUrl) { | ||
ArticleImageEntity articleImage = ArticleImageEntity.create(this, imageUrl); | ||
articleImages.add(articleImage); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/haedal/tdd/instagram/entity/article/ArticleImageEntity.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,39 @@ | ||
package haedal.tdd.instagram.entity.article; | ||
|
||
import haedal.tdd.instagram.entity.common.BaseTimeEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
@Table(name = "article_image") | ||
public class ArticleImageEntity extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "article_id") | ||
private ArticleEntity article; | ||
|
||
@Column(nullable = false, length = 200) | ||
private String imageUrl; | ||
|
||
|
||
@Builder | ||
public ArticleImageEntity(ArticleEntity article, String imageUrl) { | ||
this.article = article; | ||
this.imageUrl = imageUrl; | ||
} | ||
|
||
public static ArticleImageEntity create(ArticleEntity article, String imageUrl) { | ||
return ArticleImageEntity.builder() | ||
.article(article) | ||
.imageUrl(imageUrl) | ||
.build(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/haedal/tdd/instagram/entity/article/ArticleLikeEntity.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,39 @@ | ||
package haedal.tdd.instagram.entity.article; | ||
|
||
import haedal.tdd.instagram.entity.common.BaseTimeEntity; | ||
import haedal.tdd.instagram.entity.member.MemberEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
@Table(name = "article_like", uniqueConstraints = { | ||
@UniqueConstraint( | ||
name = "article_member_unique", | ||
columnNames = {"article_id", "member_id"} | ||
) | ||
} ) | ||
public class ArticleLikeEntity extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "article_id") | ||
private ArticleEntity article; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private MemberEntity member; | ||
|
||
@Builder | ||
public ArticleLikeEntity(ArticleEntity article, MemberEntity member) { | ||
this.article = article; | ||
this.member = member; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/haedal/tdd/instagram/entity/article/CommentEntity.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,37 @@ | ||
package haedal.tdd.instagram.entity.article; | ||
|
||
import haedal.tdd.instagram.entity.common.BaseTimeEntity; | ||
import haedal.tdd.instagram.entity.member.MemberEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
@Table(name = "comment") | ||
public class CommentEntity extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String content; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "article_id") | ||
private ArticleEntity article; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private MemberEntity member; | ||
|
||
@Builder | ||
public CommentEntity(String content, ArticleEntity article, MemberEntity member) { | ||
this.content = content; | ||
this.article = article; | ||
this.member = member; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/haedal/tdd/instagram/entity/article/CommentLikeEntity.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 haedal.tdd.instagram.entity.article; | ||
|
||
import haedal.tdd.instagram.entity.common.BaseTimeEntity; | ||
import haedal.tdd.instagram.entity.member.MemberEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
@Table(name = "comment_like", uniqueConstraints = { | ||
@UniqueConstraint( | ||
name = "comment_member_unique", | ||
columnNames = {"comment_id", "member_id"} | ||
) | ||
}) | ||
public class CommentLikeEntity extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "comment_id") | ||
private CommentEntity comment; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private MemberEntity member; | ||
|
||
@Builder | ||
public CommentLikeEntity(CommentEntity comment, MemberEntity member) { | ||
this.comment = comment; | ||
this.member = member; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/haedal/tdd/instagram/entity/common/BaseTimeEntity.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,20 @@ | ||
package haedal.tdd.instagram.entity.common; | ||
|
||
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; | ||
|
||
@MappedSuperclass | ||
@Getter | ||
@EntityListeners(AuditingEntityListener.class) | ||
public abstract class BaseTimeEntity { | ||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
@LastModifiedDate | ||
private LocalDateTime updatedAt; | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/haedal/tdd/instagram/entity/member/MemberEntity.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 haedal.tdd.instagram.entity.member; | ||
|
||
import haedal.tdd.instagram.entity.common.BaseTimeEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
@Table(name = "member") | ||
public class MemberEntity extends BaseTimeEntity { | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false, length = 20) | ||
private String nickname; | ||
|
||
@Column(unique = true, nullable = false, length = 50) | ||
private String email; | ||
|
||
@Column(length = 100) | ||
private String password; | ||
|
||
@Column(unique = true, length = 50) | ||
private String facebookId; | ||
|
||
@Column(nullable = false) | ||
private LocalDate birthDate; | ||
|
||
@Column(length = 200) | ||
private String profileImageUrl; | ||
|
||
@Builder | ||
public MemberEntity(String nickname, String email, String password, String facebookId, LocalDate birthDate, String profileImageUrl) { | ||
this.nickname = nickname; | ||
this.email = email; | ||
this.password = password; | ||
this.facebookId = facebookId; | ||
this.birthDate = birthDate; | ||
this.profileImageUrl = profileImageUrl; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/haedal/tdd/instagram/entity/member/MemberFollowEntity.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,37 @@ | ||
package haedal.tdd.instagram.entity.member; | ||
|
||
|
||
import haedal.tdd.instagram.entity.common.BaseTimeEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
@Table(name = "member_follow", uniqueConstraints = { | ||
@UniqueConstraint( | ||
name = "member_follow_uk", | ||
columnNames = {"following", "followed"} | ||
) | ||
}) | ||
public class MemberFollowEntity extends BaseTimeEntity { | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "following") | ||
private MemberEntity followingMember; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "followed") | ||
private MemberEntity followedMember; | ||
|
||
@Builder | ||
public MemberFollowEntity(MemberEntity followingMember, MemberEntity followedMember) { | ||
this.followingMember = followingMember; | ||
this.followedMember = followedMember; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/haedal/tdd/instagram/entity/story/StoryEntity.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,31 @@ | ||
package haedal.tdd.instagram.entity.story; | ||
|
||
import haedal.tdd.instagram.entity.common.BaseTimeEntity; | ||
import haedal.tdd.instagram.entity.member.MemberEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
@Table(name = "story") | ||
public class StoryEntity extends BaseTimeEntity { | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false, length = 200) | ||
private String imageUrl; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private MemberEntity member; | ||
|
||
@Builder | ||
public StoryEntity(String imageUrl, MemberEntity member) { | ||
this.imageUrl = imageUrl; | ||
this.member = member; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/haedal/tdd/instagram/repository/article/ArticleImageJpaRepository.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,7 @@ | ||
package haedal.tdd.instagram.repository.article; | ||
|
||
import haedal.tdd.instagram.entity.article.ArticleImageEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ArticleImageJpaRepository extends JpaRepository<ArticleImageEntity, Long> { | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/haedal/tdd/instagram/repository/article/ArticleJpaRepository.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 haedal.tdd.instagram.repository.article; | ||
|
||
import haedal.tdd.instagram.entity.article.ArticleEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
|
||
public interface ArticleJpaRepository extends JpaRepository<ArticleEntity, Long> { | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
깡통 JpaConfig에 @EnableJpaAuditing을 올렸다는게 인상