-
Notifications
You must be signed in to change notification settings - Fork 8
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
[BE] 도메인 설계 수정 반영 #27
Changes from 10 commits
5c332f3
31557fa
e5db20a
a41584e
8afbda8
cbd7679
2eb29c0
c9d9d3f
7fdb7da
b212de4
8e61e35
1d2d868
d07062b
2b94e43
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 |
---|---|---|
@@ -1,33 +1,47 @@ | ||
package com.woowacourse.momo.domain.guest; | ||
package com.woowacourse.momo.domain.attendee; | ||
|
||
import com.woowacourse.momo.domain.BaseEntity; | ||
import com.woowacourse.momo.domain.meeting.Meeting; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embedded; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
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.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Table(name = "guest") | ||
@Table(name = "attendee") | ||
@Entity | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Guest extends BaseEntity { | ||
public class Attendee extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "meeting_id", nullable = false) | ||
private Meeting meeting; | ||
|
||
@Embedded | ||
@Column(nullable = false, length = 20) | ||
private GuestName name; | ||
private AttendeeName name; | ||
|
||
@Column(nullable = false) | ||
private String password; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(length = 10) | ||
private Role role; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.woowacourse.momo.domain.attendee; | ||
|
||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface AttendeeRepository extends JpaRepository<Attendee, Long> { | ||
|
||
Optional<Attendee> findByName(AttendeeName name); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.woowacourse.momo.domain.attendee; | ||
|
||
public enum Role { | ||
HOST, GUEST | ||
} | ||
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
package com.woowacourse.momo.domain.schedule; | ||
|
||
import com.woowacourse.momo.domain.guest.Guest; | ||
import com.woowacourse.momo.domain.meeting.Meeting; | ||
import com.woowacourse.momo.domain.attendee.Attendee; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ScheduleRepository extends JpaRepository<Schedule, Long> { | ||
|
||
List<Schedule> findAllByMeeting(Meeting meeting); | ||
List<Schedule> findAllByAttendee(Attendee attendee); | ||
|
||
void deleteAllByMeetingAndGuest(Meeting meeting, Guest guest); | ||
void deleteAllByAttendee(Attendee attendee); | ||
} |
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. dto 클래스의 위치는 다른 곳과 같이 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.
생성시간/수정시간을 로그성 정보를 저장한다는 점은 생각지 못했네요! 꼭 필요할 것 같습니다. 다만, 현재 참가자가 시간을 수정할 때 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.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package com.woowacourse.momo.service.meeting; | ||
|
||
import com.woowacourse.momo.domain.attendee.Attendee; | ||
import com.woowacourse.momo.domain.availabledate.AvailableDate; | ||
import com.woowacourse.momo.domain.availabledate.AvailableDateRepository; | ||
import com.woowacourse.momo.domain.meeting.Meeting; | ||
import com.woowacourse.momo.domain.meeting.MeetingRepository; | ||
import com.woowacourse.momo.service.meeting.dto.MeetingResponse; | ||
import com.woowacourse.momo.domain.schedule.Schedule; | ||
import com.woowacourse.momo.domain.schedule.ScheduleRepository; | ||
import com.woowacourse.momo.domain.schedule.dto.ScheduleTimeResponse; | ||
import com.woowacourse.momo.service.meeting.dto.MeetingResponse; | ||
import java.time.LocalDate; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
@@ -36,7 +37,8 @@ public MeetingResponse findByUUID(String uuid) { | |
.map(AvailableDate::getDate) | ||
.toList(); | ||
|
||
List<Schedule> schedules = scheduleRepository.findAllByMeeting(meeting); | ||
Attendee attendee = null; | ||
List<Schedule> schedules = scheduleRepository.findAllByAttendee(attendee); | ||
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. 이 부분은 왜 이런 구조로 변경되었는지 궁금합니다! 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. 일단 테스트를 통과시켜야 해서 변경했습니다. |
||
Map<AvailableDate, List<Schedule>> collected = schedules.stream() | ||
.collect(Collectors.groupingBy(Schedule::getAvailableDate)); | ||
List<ScheduleTimeResponse> list = collected.entrySet().stream() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.woowacourse.momo.domain.attendee; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatNoException; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class AttendeeNameTest { | ||
|
||
@Test | ||
@DisplayName("참여자 이름이 20글자를 초과하면 예외를 발생시킨다.") | ||
void throwsExceptionIfAttendeeNameIsTooLong() { | ||
assertThatThrownBy(() -> new AttendeeName("woowacourse-momo-jjangjjanng-momo")) | ||
.isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("참여자 이름 객체가 정상 생성된다.") | ||
void createAttendeeNameObjectSuccessfully() { | ||
assertThatNoException() | ||
.isThrownBy(() -> new AttendeeName("momo")); | ||
} | ||
} |
This file was deleted.
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.
줄바꿈 컨벤션이 빠져있는거 같아요!