-
Notifications
You must be signed in to change notification settings - Fork 1
[Fix] 1차 스프린트 ERD 수정 #76
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cc580fe
refactor: 사용하지 않는 도메인 제거
leegwichan 0c61e3d
fix: Store 도메인 수정
leegwichan a5e79e8
feat: Cheer 도메인 구현
leegwichan d648ab6
feat: Article 도메인 구현
leegwichan 2135166
fix: SQL 문 수정
leegwichan 0926c99
fix: Cheer 의 생성자 수정
leegwichan b27f9f0
refactor(AuditingEntity): 생성 시각 분리
leegwichan 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 hidden or 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,46 @@ | ||
| package eatda.domain.article; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDateTime; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Table(name = "article") | ||
| @Entity | ||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class Article { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false) | ||
| private String title; | ||
|
|
||
| @Column(nullable = false) | ||
| private String subtitle; | ||
|
|
||
| @Column(name = "article_url", nullable = false, length = 511) | ||
| private String articleUrl; | ||
|
|
||
| @Column(name = "image_key", nullable = false, length = 511) | ||
| private String imageKey; | ||
|
|
||
| @Column(name = "created_at", nullable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| public Article(String title, String subtitle, String articleUrl, String imageKey) { | ||
| this.title = title; | ||
| this.subtitle = subtitle; | ||
| this.articleUrl = articleUrl; | ||
| this.imageKey = imageKey; | ||
| this.createdAt = LocalDateTime.now(); | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDateTime; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
@@ -41,12 +42,16 @@ public class Member { | |
| @Column(name = "opt_in_marketing") | ||
| private Boolean optInMarketing; | ||
|
|
||
| @Column(name = "created_at", nullable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| public Member(String socialId, String email, String nickname) { | ||
| validateSocialId(socialId); | ||
| validateEmail(email); | ||
| this.socialId = socialId; | ||
| this.email = email; | ||
| this.nickname = nickname; | ||
| this.createdAt = LocalDateTime.now(); | ||
|
||
| } | ||
|
|
||
| public Member( | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,74 @@ | ||
| package eatda.domain.store; | ||
|
|
||
| import eatda.domain.member.Member; | ||
| import eatda.exception.BusinessErrorCode; | ||
| import eatda.exception.BusinessException; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDateTime; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Table(name = "cheer") | ||
| @Entity | ||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class Cheer { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "member_id", nullable = false) | ||
| private Member member; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "store_id", nullable = false) | ||
| private Store store; | ||
|
|
||
| @Column(nullable = false, columnDefinition = "TEXT") | ||
| private String description; | ||
|
|
||
| @Column(name = "image_key", nullable = false, length = 511) | ||
| private String imageKey; | ||
lvalentine6 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @Column(name = "is_admin", nullable = false) | ||
| private boolean isAdmin; | ||
|
|
||
| @Column(name = "created_at", nullable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| public Cheer(Long id, Member member, Store store, String description, String imageKey) { | ||
| validateDescription(description); | ||
| validateImageKey(imageKey); | ||
| this.id = id; | ||
| this.member = member; | ||
| this.store = store; | ||
| this.description = description; | ||
| this.imageKey = imageKey; | ||
|
|
||
| this.isAdmin = false; | ||
| this.createdAt = LocalDateTime.now(); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private void validateDescription(String description) { | ||
| if (description == null || description.isBlank()) { | ||
| throw new BusinessException(BusinessErrorCode.INVALID_CHEER_DESCRIPTION); | ||
| } | ||
| } | ||
|
|
||
| private void validateImageKey(String imageKey) { | ||
| if (imageKey != null && imageKey.isBlank()) { | ||
| throw new BusinessException(BusinessErrorCode.INVALID_CHEER_IMAGE_KEY); | ||
| } | ||
| } | ||
| } | ||
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.
[제안]
createdAt 필드는 아래처럼
@PrePersist를 활용하면 JPA 생명주기와도 맞고 테스트도 더 수월할 것 같아요!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.
좋은 아이디어라고 생각합니다.
모든 Entity마다 해당 메서드가 있는 것은 불편하다고 생각해서 AuditingEntity로 해당 부분을 분리했습니다. 확인 한 번 부탁드립니다!