-
Notifications
You must be signed in to change notification settings - Fork 2
refactor/KD-29 Lab, Club, Professor, About의 도메인과 JPA 엔티티 분리 #267
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
69a7fae
refactor/#KD-29 About.java 엔티티 도메인 분리
dkdltm221 7141820
refactor/#KD-29 Club.java 엔티티 도메인 분리 및 테스트 환경 update로직 수정
dkdltm221 a76804e
refactor/#KD-29 Lab.java 엔티티 도메인 분리 및 테스트 환경 update로직 수정
dkdltm221 f2e906e
refactor/#KD-29 Professor.java 엔티티 도메인 분리 및 테스트 환경 update로직,delete로직 수정
dkdltm221 b6e6430
refactor/#KD-29 기존FakeRepository도메인 참조에서 Jpa엔티티기반으로 테스트 코드 수정
dkdltm221 e78544e
refactor/#KD-29 FakeLabRepository.java fileId누락 수정
dkdltm221 14e8d6f
refactor/#KD-29 fakeFileRepository.save할때 physicalPath 추가
dkdltm221 0095f17
refactor/#KD-29 fromeDomain -> toEntity 매서드 이름 수정
dkdltm221 905833f
refactor/#KD-29 병합 충돌 해결
dkdltm221 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
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
23 changes: 2 additions & 21 deletions
23
aics-domain/src/main/java/kgu/developers/domain/about/domain/About.java
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
50 changes: 50 additions & 0 deletions
50
aics-domain/src/main/java/kgu/developers/domain/about/infrastructure/AboutJpaEntity.java
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,50 @@ | ||
| package kgu.developers.domain.about.infrastructure; | ||
|
|
||
| import static jakarta.persistence.EnumType.STRING; | ||
| import static jakarta.persistence.GenerationType.IDENTITY; | ||
| import static lombok.AccessLevel.PROTECTED; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import kgu.developers.common.domain.BaseTimeEntity; | ||
| import kgu.developers.domain.about.domain.About; | ||
| import kgu.developers.domain.about.domain.Category; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Entity | ||
| @Table(name ="\"about\"") | ||
| @Builder | ||
| @Getter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor(access = PROTECTED) | ||
| public class AboutJpaEntity extends BaseTimeEntity { | ||
| @Id | ||
| @GeneratedValue(strategy = IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false, unique = true) | ||
| @Enumerated(STRING) | ||
| private Category category; | ||
|
|
||
| @Column(nullable = false, columnDefinition = "text") | ||
| private String content; | ||
|
|
||
|
|
||
| public About toDomain(){ | ||
| return About.builder() | ||
| .id(this.id) | ||
| .category(this.category) | ||
| .content(this.content) | ||
| .build(); | ||
| } | ||
| public static AboutJpaEntity toEntity(About about){ | ||
| return AboutJpaEntity.builder() | ||
| .id(about.getId()) | ||
| .category(about.getCategory()) | ||
| .content(about.getContent()) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
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
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
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
56 changes: 56 additions & 0 deletions
56
aics-domain/src/main/java/kgu/developers/domain/club/infrastructure/ClubJpaEntity.java
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,56 @@ | ||
| package kgu.developers.domain.club.infrastructure; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import kgu.developers.common.domain.BaseTimeEntity; | ||
| import kgu.developers.domain.club.domain.Club; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import static jakarta.persistence.GenerationType.IDENTITY; | ||
| import static lombok.AccessLevel.PROTECTED; | ||
|
|
||
| @Entity | ||
| @Table(name = "\"club\"") | ||
| @Builder | ||
| @Getter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor(access = PROTECTED) | ||
| public class ClubJpaEntity extends BaseTimeEntity { | ||
| @Id | ||
| @GeneratedValue(strategy = IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false, unique = true, length = 16) | ||
| private String name; | ||
|
|
||
| @Column(nullable = false, length = 100) | ||
| private String description; | ||
|
|
||
| @Column(length = 50) | ||
| private String site; | ||
|
|
||
| private Long fileId; | ||
|
|
||
|
|
||
| public Club toDomain() { | ||
| return Club.builder() | ||
| .id(id) | ||
| .name(name) | ||
| .description(description) | ||
| .site(site) | ||
| .fileId(fileId) | ||
| .build(); | ||
| } | ||
| public static ClubJpaEntity toEntity(Club club) { | ||
| return ClubJpaEntity.builder() | ||
| .id(club.getId()) | ||
| .name(club.getName()) | ||
| .description(club.getDescription()) | ||
| .site(club.getSite()) | ||
| .fileId(club.getFileId()) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
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
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
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
26 changes: 2 additions & 24 deletions
26
aics-domain/src/main/java/kgu/developers/domain/lab/domain/Lab.java
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
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
60 changes: 60 additions & 0 deletions
60
aics-domain/src/main/java/kgu/developers/domain/lab/infrastructure/LabJpaEntity.java
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,60 @@ | ||
| package kgu.developers.domain.lab.infrastructure; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import kgu.developers.common.domain.BaseTimeEntity; | ||
| import kgu.developers.domain.lab.domain.Lab; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import static jakarta.persistence.GenerationType.IDENTITY; | ||
| import static lombok.AccessLevel.PROTECTED; | ||
|
|
||
|
|
||
| @Entity | ||
| @Table(name = "\"lab\"") | ||
| @Builder | ||
| @Getter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor(access = PROTECTED) | ||
| public class LabJpaEntity extends BaseTimeEntity { | ||
| @Id | ||
| @GeneratedValue(strategy = IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false, length = 16) | ||
| private String name; | ||
|
|
||
| @Column(nullable = false, length = 10) | ||
| private String loc; | ||
|
|
||
| @Column(nullable = false, length = 50) | ||
| private String site; | ||
|
|
||
| @Column(nullable = false, length = 16) | ||
| private String advisor; | ||
|
|
||
| private Long fileId; | ||
|
|
||
| public Lab toDomain(){ | ||
| return Lab.builder() | ||
| .id(id) | ||
| .name(name) | ||
| .loc(loc) | ||
| .site(site) | ||
| .advisor(advisor) | ||
| .fileId(fileId) | ||
| .build(); | ||
| } | ||
| public static LabJpaEntity toEntity(Lab lab) { | ||
| return LabJpaEntity.builder() | ||
| .id(lab.getId()) | ||
| .name(lab.getName()) | ||
| .loc(lab.getLoc()) | ||
| .site(lab.getSite()) | ||
| .advisor(lab.getAdvisor()) | ||
| .fileId(lab.getFileId()) | ||
| .build(); | ||
| } | ||
| } |
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.
카테고리 유니크 제약 사전 검증/예외 변환 필요
DB 레벨에서 category가 unique인데, 사전 검증 없이 생성 시 DataIntegrityViolationException으로 터질 수 있습니다. 도메인 친화적 예외로 변환하거나, 생성 전에 존재 여부를 체크하세요.
간단한 선행 체크 예시:
public Long createAbout(Category category, String content) { + if (aboutRepository.findByCategory(category).isPresent()) { + // TODO: 도메인 전용 예외(예: AboutAlreadyExistsException)로 치환 + throw new IllegalStateException("이미 존재하는 카테고리: " + category); + } About about = About.create(category, content); About savedAbout = aboutRepository.save(about); return savedAbout.getId(); }📝 Committable suggestion
🤖 Prompt for AI Agents