-
Notifications
You must be signed in to change notification settings - Fork 309
3단계 - 수강신청(DB 적용) #835
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
3단계 - 수강신청(DB 적용) #835
Changes from all commits
Commits
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
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
10 changes: 10 additions & 0 deletions
10
src/main/java/nextstep/courses/domain/CoverImageRepository.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,10 @@ | ||
| package nextstep.courses.domain; | ||
|
|
||
| import nextstep.courses.domain.image.CoverImage; | ||
|
|
||
| public interface CoverImageRepository { | ||
|
|
||
| int save(CoverImage coverImage); | ||
|
|
||
| CoverImage findBySessionId(Long sessionId); | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/nextstep/courses/domain/EnrollmentRepository.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,11 @@ | ||
| package nextstep.courses.domain; | ||
|
|
||
| import java.util.List; | ||
| import nextstep.courses.domain.enrollment.Enrollment; | ||
|
|
||
| public interface EnrollmentRepository { | ||
|
|
||
| Long save(Enrollment enrollment); | ||
|
|
||
| List<Enrollment> findBySessionId(Long sessionId); | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/main/java/nextstep/courses/domain/SessionRepository.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,14 @@ | ||
| package nextstep.courses.domain; | ||
|
|
||
| import java.util.List; | ||
| import nextstep.courses.domain.session.Session; | ||
|
|
||
| public interface SessionRepository { | ||
|
|
||
| Long save(Session session); | ||
|
|
||
| Session findById(Long id); | ||
|
|
||
| List<Session> findByCourseId(Long courseId); | ||
|
|
||
| } |
27 changes: 27 additions & 0 deletions
27
src/main/java/nextstep/courses/domain/enrollment/Enrollment.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,27 @@ | ||
| package nextstep.courses.domain.enrollment; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import nextstep.core.domain.BaseEntity; | ||
|
|
||
| public class Enrollment extends BaseEntity { | ||
| private final Long sessionId; | ||
| private final Long userId; | ||
|
|
||
| public Enrollment(Long sessionId, Long userId) { | ||
| this(null, sessionId, userId, LocalDateTime.now(), null); | ||
| } | ||
|
|
||
| public Enrollment(Long id, Long sessionId, Long userId, LocalDateTime createdAt, LocalDateTime updatedAt) { | ||
| super(id, createdAt, updatedAt); | ||
| this.sessionId = sessionId; | ||
| this.userId = userId; | ||
| } | ||
|
|
||
| public Long getSessionId() { | ||
| return sessionId; | ||
| } | ||
|
|
||
| public Long getUserId() { | ||
| return userId; | ||
| } | ||
| } |
41 changes: 38 additions & 3 deletions
41
src/main/java/nextstep/courses/domain/image/CoverImage.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
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
74 changes: 65 additions & 9 deletions
74
src/main/java/nextstep/courses/domain/session/Session.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 |
|---|---|---|
| @@ -1,24 +1,80 @@ | ||
| package nextstep.courses.domain.session; | ||
|
|
||
| import nextstep.courses.domain.image.CoverImage; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import nextstep.core.domain.SoftDeletableBaseEntity; | ||
| import nextstep.payments.domain.Payment; | ||
| import nextstep.users.domain.NsUser; | ||
|
|
||
| public class Session { | ||
| private final Students students = new Students(); | ||
| private final Period period; | ||
| private final CoverImage coverImage; | ||
| private final SessionStatus sessionStatus; | ||
| private final EnrollmentPolicy enrollmentPolicy; | ||
| public class Session extends SoftDeletableBaseEntity { | ||
|
Contributor
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. 수강 신청 기능을 처리하기 위해 도메인 객체와 Repository를 연결하는 Service 객체를 추가해 보면 어떨까? |
||
| private Long courseId; | ||
| private Students students = new Students(); | ||
| private Period period; | ||
| private SessionStatus sessionStatus; | ||
| private EnrollmentPolicy enrollmentPolicy; | ||
|
|
||
| public Session(Period period, CoverImage coverImage, SessionStatus sessionStatus, | ||
| public Session(Long courseId, Period period, SessionStatus sessionStatus, | ||
| EnrollmentPolicy enrollmentPolicy) { | ||
| this(0L, courseId, period, sessionStatus, enrollmentPolicy, LocalDateTime.now(), null); | ||
| } | ||
|
|
||
| public Session(Long id, Long courseId, Period period, SessionStatus sessionStatus, | ||
| EnrollmentPolicy enrollmentPolicy, LocalDateTime createdAt, LocalDateTime updatedAt) { | ||
| super(id, createdAt, updatedAt); | ||
| this.courseId = courseId; | ||
| this.period = period; | ||
| this.coverImage = coverImage; | ||
| this.sessionStatus = sessionStatus; | ||
| this.enrollmentPolicy = enrollmentPolicy; | ||
| } | ||
|
|
||
| public Long getCourseId() { | ||
| return courseId; | ||
| } | ||
|
|
||
| public Students getStudents() { | ||
| return students; | ||
| } | ||
|
|
||
| public Period getPeriod() { | ||
| return period; | ||
| } | ||
|
|
||
| public SessionStatus getSessionStatus() { | ||
| return sessionStatus; | ||
| } | ||
|
|
||
| public String getSessionStatusName() { | ||
| return sessionStatus.name(); | ||
| } | ||
|
|
||
| public EnrollmentPolicy getEnrollmentPolicy() { | ||
| return enrollmentPolicy; | ||
| } | ||
|
|
||
| public LocalDate getStartDate() { | ||
| return period.getStartDate(); | ||
| } | ||
|
|
||
| public LocalDate getEndDate() { | ||
| return period.getEndDate(); | ||
| } | ||
|
|
||
| public SessionType getSessionType() { | ||
| return enrollmentPolicy.getSessionType(); | ||
| } | ||
|
|
||
| public String getSessionTypeName() { | ||
| return enrollmentPolicy.getSessionTypeName(); | ||
| } | ||
|
|
||
| public int getCapacity() { | ||
| return enrollmentPolicy.getCapacity(); | ||
| } | ||
|
|
||
| public long getFee() { | ||
| return enrollmentPolicy.getFee(); | ||
| } | ||
|
|
||
| public void enroll(NsUser user) { | ||
| enroll(user, null); | ||
| } | ||
|
|
||
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.
1단계 미션의 SoftDeletableBaseEntity 활용 👍