diff --git a/src/main/java/org/sophy/sophy/domain/AuthorProperty.java b/src/main/java/org/sophy/sophy/domain/AuthorProperty.java index 4294f41..c4bacaa 100644 --- a/src/main/java/org/sophy/sophy/domain/AuthorProperty.java +++ b/src/main/java/org/sophy/sophy/domain/AuthorProperty.java @@ -21,16 +21,6 @@ public class AuthorProperty { @OneToMany(mappedBy = "authorProperty", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List myBookTalkList; - private Integer myBookTalkSize; - - public void plusMyBookTalkSize() { - this.myBookTalkSize += 1; - } - - public void minusMyBookTalkSize() { // 북토크가 완료 되었을 때 (개최한 북토크 -> 참여한 북토크로 변하는지에 따라 나뉠듯) - this.myBookTalkSize -= 1; - } - @OneToMany(mappedBy = "authorProperty", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List myBookList; @@ -40,7 +30,6 @@ public void deleteBooktalk(Booktalk booktalk) { public static AuthorProperty toBuild() { return AuthorProperty.builder() - .myBookTalkSize(0) .myBookList(new ArrayList<>()) .myBookTalkList(new ArrayList<>()) .build(); diff --git a/src/main/java/org/sophy/sophy/domain/Booktalk.java b/src/main/java/org/sophy/sophy/domain/Booktalk.java index bf6d31c..61863c5 100644 --- a/src/main/java/org/sophy/sophy/domain/Booktalk.java +++ b/src/main/java/org/sophy/sophy/domain/Booktalk.java @@ -78,8 +78,6 @@ public class Booktalk extends AuditingEntity { @Column(nullable = false) private LocalDateTime endDate; - private Integer participantNum; - @Column(nullable = false) private Integer maximum; @@ -107,10 +105,6 @@ public class Booktalk extends AuditingEntity { private final Boolean deleted = Boolean.FALSE; - public void plusParticipant() { - this.participantNum += 1; - } - public void setBooktalkStatus(BooktalkStatus booktalkStatus) { this.booktalkStatus = booktalkStatus; } @@ -136,7 +130,6 @@ public void setAuthor(Member member) { this.member = member; this.authorProperty = member.getAuthorProperty(); member.getAuthorProperty().getMyBookTalkList().add(this); - member.getAuthorProperty().plusMyBookTalkSize(); } @Builder @@ -152,7 +145,6 @@ public Booktalk(Place place, String title, String booktalkImageUrl, Book book, M this.bookCategory = bookCategory; this.startDate = startDate; this.endDate = endDate; - this.participantNum = 0; this.maximum = maximum; this.participationFee = participationFee; this.preliminaryInfo = preliminaryInfo; diff --git a/src/main/java/org/sophy/sophy/domain/CompletedBooktalk.java b/src/main/java/org/sophy/sophy/domain/CompletedBooktalk.java index 27468b6..5c59456 100644 --- a/src/main/java/org/sophy/sophy/domain/CompletedBooktalk.java +++ b/src/main/java/org/sophy/sophy/domain/CompletedBooktalk.java @@ -61,6 +61,5 @@ public static CompletedBooktalk toBuild(Booktalk booktalk) { public void setMember(Member member) { this.member = member; member.getCompletedBookTalkList().add(this); - member.plusCompletedBooktalk(); } } diff --git a/src/main/java/org/sophy/sophy/domain/Member.java b/src/main/java/org/sophy/sophy/domain/Member.java index c8da501..3d09875 100644 --- a/src/main/java/org/sophy/sophy/domain/Member.java +++ b/src/main/java/org/sophy/sophy/domain/Member.java @@ -68,13 +68,9 @@ public class Member extends AuditingTimeEntity { @OneToMany(mappedBy = "member") private List userBookTalkList; // -> 참여 예정 북토크 수 - private Integer userBookTalkSize; - @OneToMany(mappedBy = "member") private List completedBookTalkList; //이거 길이로 북토크 수 보여줄 수 있지 않을까? -> 참여 완료 북토크 수 - private Integer completedBookTalkSize; - @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "author_property_id") private AuthorProperty authorProperty; //(개설한 북토크 리스트 + 나의 책 리스트 + 공간 매칭 중 북토크 수 + 청중 모집 중 북토크 수) @@ -96,21 +92,7 @@ public Member(String name, String email, String password, String phoneNum, this.authority = authority; this.socialId = socialId; this.userBookTalkList = new ArrayList<>(); - this.userBookTalkSize = 0; this.completedBookTalkList = new ArrayList<>(); - this.completedBookTalkSize = 0; - } - - public void plusUserBooktalk() { - this.userBookTalkSize += 1; - } - - public void minusUserBooktalk() { - this.userBookTalkSize -= 1; - } - - public void plusCompletedBooktalk() { - this.completedBookTalkSize += 1; } public void setAuthorProperty(AuthorProperty authorProperty) { diff --git a/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java b/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java index 24c467b..734a994 100644 --- a/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java +++ b/src/main/java/org/sophy/sophy/domain/MemberBooktalk.java @@ -32,7 +32,6 @@ public void setMember(Member member) { if (!member.getUserBookTalkList().contains(this)) { // 시작날짜로 순으로 정렬해서 추가 member.getUserBookTalkList().add(this); - member.plusUserBooktalk(); } } @@ -40,7 +39,6 @@ public void setBooktalk(Booktalk booktalk) { this.booktalk = booktalk; if (!booktalk.getParticipantList().contains(this)) { booktalk.getParticipantList().add(this); - booktalk.plusParticipant(); } } diff --git a/src/main/java/org/sophy/sophy/infrastructure/query/BooktalkQueryRepository.java b/src/main/java/org/sophy/sophy/infrastructure/query/BooktalkQueryRepository.java index c02778a..6c76b13 100644 --- a/src/main/java/org/sophy/sophy/infrastructure/query/BooktalkQueryRepository.java +++ b/src/main/java/org/sophy/sophy/infrastructure/query/BooktalkQueryRepository.java @@ -13,7 +13,7 @@ public interface BooktalkQueryRepository extends JpaRepository { @Query("select new org.sophy.sophy.domain.dto.booktalk.response.BooktalkResponseDto(" - + " b.id, b.preliminaryInfo, b.title, m.name, b.startDate, b.endDate, p.name, b.participantNum, b.maximum, b.booktalkImageUrl, b.booktalkStatus)" + + " b.id, b.preliminaryInfo, b.title, m.name, b.startDate, b.endDate, p.name, b.participantList.size, b.maximum, b.booktalkImageUrl, b.booktalkStatus)" + " from Booktalk b" + " join b.member m" + " join b.place p" @@ -47,7 +47,7 @@ List findByBooktalkStatuses( @Param("booktalkStatuses") List booktalkStatuses); @Query("select new org.sophy.sophy.domain.dto.mypage.MyPageBooktalkDto(" - + " b.id, b.booktalkImageUrl, b.title, m.name, b.startDate, b.endDate, p.name, b.participantNum, b.maximum, b.booktalkStatus)" + + " b.id, b.booktalkImageUrl, b.title, m.name, b.startDate, b.endDate, p.name, b.participantList.size, b.maximum, b.booktalkStatus)" + " from Booktalk b" + " join b.member m" + " join b.place p" diff --git a/src/main/java/org/sophy/sophy/service/BooktalkService.java b/src/main/java/org/sophy/sophy/service/BooktalkService.java index be422a6..751432b 100644 --- a/src/main/java/org/sophy/sophy/service/BooktalkService.java +++ b/src/main/java/org/sophy/sophy/service/BooktalkService.java @@ -112,7 +112,7 @@ public void postBooktalkParticipation( ErrorStatus.BOOKTALK_RECRUITING_CLOSED_EXCEPTION.getMessage()); } //북토크 현재 인원이 최대인원을 넘지 않았는지 체크하는 메서드 - if (booktalk.getMaximum() <= booktalk.getParticipantNum()) { + if (booktalk.getMaximum() <= booktalk.getParticipantList().size()) { throw new OverMaxParticipationException(ErrorStatus.OVER_MAX_PARTICIPATION_EXCEPTION, ErrorStatus.OVER_MAX_PARTICIPATION_EXCEPTION.getMessage()); } @@ -126,7 +126,7 @@ public void postBooktalkParticipation( // 복합키? memberBooktalkRepository.save( booktalkParticipationRequestDto.toMemberBooktalk(booktalk, member)); - if (booktalk.getMaximum().equals(booktalk.getParticipantNum())) { //인원이 다 찬 경우 마감 + if (booktalk.getMaximum().equals(booktalk.getParticipantList().size())) { //인원이 다 찬 경우 마감 booktalk.setBooktalkStatus(BooktalkStatus.RECRUITING_CLOSED); } } @@ -171,11 +171,9 @@ public CompletedBooktalk changeBooktalkToComplete(Booktalk booktalk) { for (MemberBooktalk memberBooktalk : booktalk.getParticipantList()) { //참가 인원들 소피스토리 세팅 Member member = memberBooktalk.getMember(); completedBooktalkSetting(booktalk, member); - member.minusUserBooktalk(); //예정된 북토크 수 감소 } Member member = booktalk.getMember(); //작가 소피스토리 세팅 CompletedBooktalk completedBooktalk = completedBooktalkSetting(booktalk, member); - member.getAuthorProperty().minusMyBookTalkSize(); //개최한 북토크 수 감소 booktalkRepository.delete(booktalk); return completedBooktalk; } diff --git a/src/main/java/org/sophy/sophy/service/HomeService.java b/src/main/java/org/sophy/sophy/service/HomeService.java index e40d885..8ee4ea5 100644 --- a/src/main/java/org/sophy/sophy/service/HomeService.java +++ b/src/main/java/org/sophy/sophy/service/HomeService.java @@ -30,7 +30,7 @@ public class HomeService { public HomeResponseDto getHome(String email) { Member member = memberRepository.getMemberByEmail(email); - Integer booktalkCount = member.getUserBookTalkSize(); + Integer booktalkCount = member.getUserBookTalkList().size(); List booktalkDeadlineUpcoming = booktalkService.getBooktalkDeadlineUpcoming(); if (member.getAuthority().equals(Authority.AUTHOR)) { //작가냐 아니냐에 따라 홈 화면 분리