-
Notifications
You must be signed in to change notification settings - Fork 1
[fix] 연관 관계를 수정 #37
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
[fix] 연관 관계를 수정 #37
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,9 +43,6 @@ public class GithubRepo { | |
| @OneToMany(mappedBy = "githubRepo", cascade = CascadeType.ALL) | ||
| private List<Contributor> contributors = new ArrayList<>(); | ||
|
|
||
| @OneToMany(mappedBy = "githubRepo") | ||
| private List<NotificationAgreement> notificationAgreements = new ArrayList<>(); | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "user_id") | ||
| private User user; | ||
|
|
@@ -67,8 +64,7 @@ public void addContributors(List<Contributor> contributors) { | |
|
|
||
| public void setNotificationAgreement(List<NotificationAgreement> agreements) { | ||
| for (NotificationAgreement agreement : agreements) { | ||
| this.notificationAgreements.add(agreement); | ||
| agreement.setGitHubRepo(this); | ||
| agreement.setGitHubRepoId(this.getId()); | ||
| } | ||
|
||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ public interface GithubRepoMapper { | |
|
|
||
| default GithubRepoCreateResponse toGithubRepoCreateResponse(String owner, | ||
| String reponame) { | ||
|
|
||
| return new GithubRepoCreateResponse( | ||
| owner, | ||
| reponame | ||
|
Comment on lines
18
to
23
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 클래스의 매핑 메서드들에
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
owner와 reponame 두 개의 파라미터를 받아 Response를 생성하는 방식은 MapStruct가 처리할 수 없기 때문에 default를 사용했습니다.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좀 더 상세히 설명주시겠어요? Mapstruct가 |
||
|
|
@@ -26,12 +27,12 @@ default GithubRepoCreateResponse toGithubRepoCreateResponse(String owner, | |
|
|
||
| default GithubRepoGetResponse toGithubRepoGetResponse(GithubRepo repo, String owner, | ||
| String reponame, Long userId) { | ||
|
|
||
| return new GithubRepoGetResponse( | ||
| userId, | ||
| repo.getId(), | ||
| repo.getName(), | ||
| repo.getUrl(), | ||
| repo.getNotificationAgreements(), | ||
| repo.getEndDate(), | ||
| owner, | ||
| reponame | ||
|
|
@@ -42,6 +43,7 @@ default GithubRepoGetResponse toGithubRepoGetResponse(GithubRepo repo, String ow | |
| GithubRepoSummary toGithubRepoSummary(GithubRepo repo); | ||
|
|
||
| default GithubRepoPageResponse toGithubRepoPageResponse(Page<GithubRepo> page, Long userId) { | ||
|
|
||
| return new GithubRepoPageResponse( | ||
| page.getContent().stream() | ||
| .map(this::toGithubRepoSummary) | ||
|
|
@@ -54,6 +56,7 @@ default GithubRepoPageResponse toGithubRepoPageResponse(Page<GithubRepo> page, L | |
| } | ||
|
|
||
| default GithubRepoDeleteResponse toGithubDeleteRepoResponse() { | ||
|
|
||
| return new GithubRepoDeleteResponse( | ||
| true | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,16 +1,13 @@ | ||||||||||
| package com.specialwarriors.conal.notification.domain; | ||||||||||
|
|
||||||||||
| import com.specialwarriors.conal.github_repo.domain.GithubRepo; | ||||||||||
| import com.specialwarriors.conal.notification.converter.NotificationTypeConverter; | ||||||||||
| import com.specialwarriors.conal.notification.enums.NotificationType; | ||||||||||
| import jakarta.persistence.Column; | ||||||||||
| import jakarta.persistence.Convert; | ||||||||||
| 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 lombok.AccessLevel; | ||||||||||
| import lombok.Getter; | ||||||||||
|
|
@@ -28,9 +25,8 @@ public class NotificationAgreement { | |||||||||
|
|
||||||||||
| private boolean isAgree; | ||||||||||
|
|
||||||||||
| @ManyToOne(fetch = FetchType.EAGER) | ||||||||||
| @JoinColumn(name = "github_repo_id") | ||||||||||
| private GithubRepo githubRepo; | ||||||||||
| @Column(name = "github_repo_id", nullable = false) | ||||||||||
| private Long githubRepoId; | ||||||||||
|
||||||||||
| @Column(name = "github_repo_id", nullable = false) | |
| private Long githubRepoId; | |
| @Column(name = "github_repo_id") | |
| private long githubRepoId; |
기본 타입으로 설정할 경우 굳이 래퍼 타입을 쓰고 nullable=false를 설정할 필요가 없습니다. 굳이 래퍼 타입을 쓰신 이유가 있다면 설명 부탁드립니다.
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.
기본 타입으로 설정할 경우 굳이 래퍼 타입을 쓰고
nullable=false를 설정할 필요가 없습니다. 굳이 래퍼 타입을 쓰신 이유가 있다면 설명 부탁드립니다.
몰랐습니다! 수정하겠습니다
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,19 @@ | ||
| package com.specialwarriors.conal.notification.repository; | ||
|
|
||
| import com.specialwarriors.conal.github_repo.domain.GithubRepo; | ||
| import com.specialwarriors.conal.notification.domain.NotificationAgreement; | ||
| import com.specialwarriors.conal.notification.enums.NotificationType; | ||
| import java.util.List; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public interface NotificationAgreementRepository extends JpaRepository<NotificationAgreement, Long> { | ||
| public interface NotificationAgreementRepository extends | ||
| JpaRepository<NotificationAgreement, Long> { | ||
|
|
||
| List<NotificationAgreement> findAllByGithubRepoAndNotificationType(GithubRepo githubRepo, | ||
| NotificationType notificationType); | ||
| List<NotificationAgreement> findAllByGithubRepoIdAndNotificationType(Long githubRepoId, | ||
| NotificationType notificationType); | ||
|
|
||
| List<NotificationAgreement> findAllByNotificationType(NotificationType notificationType); | ||
|
|
||
| void deleteByGithubRepo(GithubRepo repo); | ||
| void deleteByGithubRepoId(Long githubRepoId); | ||
|
||
| } | ||
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.
리스트 타입의 변수가 단수형으로 지어질 경우 의미가 불명확해진다고 생각합니다. 수정 부탁드립니다.
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.
넵!