-
Notifications
You must be signed in to change notification settings - Fork 247
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
[Step4] 수강신청(요구사항 변경) #512
base: danden1
Are you sure you want to change the base?
Changes from all commits
4825879
7db46f5
82afb5f
690897c
372a860
977df36
cb8eb42
c81b977
9f9f537
44ed16a
b9b560a
1c0881a
bad0ea4
c2213de
e8faf76
df34cef
f01b24a
747c740
8ce5938
fe7d691
34b4074
46b8d46
bd50aa3
7da41fc
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nextstep.courses.domain; | ||
|
||
import java.util.Optional; | ||
|
||
public interface FreeSessionRepository { | ||
Sessions findByCourseId(Long courseId); | ||
|
||
Optional<FreeSession> findBySessionId(Long sessionId); | ||
|
||
void saveSession(FreeSession session, Long courseId); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nextstep.courses.domain; | ||
|
||
import java.util.Optional; | ||
|
||
public interface PaySessionRepository { | ||
Sessions findByCourseId(Long courseId); | ||
|
||
Optional<PaySession> findBySessionId(Long sessionId); | ||
|
||
void saveSession(PaySession session, Long courseId); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package nextstep.courses.domain; | ||
|
||
public enum RecruitStatus { | ||
|
||
RECRUIT, | ||
NOT_RECRUIT; | ||
|
||
public static RecruitStatus findByName(String name) { | ||
return RecruitStatus.valueOf(name.toUpperCase()); | ||
} | ||
|
||
public boolean isRecruit() { | ||
return this.equals(RECRUIT); | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,29 +4,40 @@ | |
import nextstep.payments.domain.Payment; | ||
import nextstep.users.domain.NsUser; | ||
|
||
import java.time.LocalDate; | ||
import java.util.HashSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.*; | ||
|
||
public abstract class Session { | ||
|
||
private final Long id; | ||
private final SessionImage sessionImage; | ||
private SessionStatus sessionStatus; | ||
private final List<SessionImage> sessionImage; | ||
private RecruitStatus recruitStatus; | ||
private SessionProgressStatus sessionProgressStatus; | ||
private final Set<NsUser> students; | ||
private final Set<NsUser> approveStudents; | ||
Comment on lines
+12
to
+16
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.
'수강신청'과 관련된 필드만 모아서 객체를 도출하면 어떨까요? |
||
private final SessionDate sessionDate; | ||
|
||
public Session(Long id, SessionImage sessionImage, SessionStatus sessionStatus, SessionDate sessionDate) { | ||
this(id, sessionImage,sessionStatus, sessionDate, new HashSet<>()); | ||
|
||
public Session(Long id, List<SessionImage> sessionImage, RecruitStatus recruitStatus, SessionDate sessionDate) { | ||
this(id, sessionImage, recruitStatus, sessionDate, new HashSet<>()); | ||
} | ||
|
||
public Session(Long id, List<SessionImage> sessionImage, RecruitStatus recruitStatus, SessionProgressStatus sessionProgressStatus, SessionDate sessionDate) { | ||
this(id, sessionImage, recruitStatus, sessionProgressStatus, sessionDate, new HashSet<>(), new HashSet<>()); | ||
} | ||
|
||
public Session(Long id, List<SessionImage> sessionImage, RecruitStatus recruitStatus, SessionDate sessionDate, Set<NsUser> students) { | ||
this(id, sessionImage, recruitStatus, SessionProgressStatus.PREPARE, sessionDate, students, new HashSet<>()); | ||
} | ||
|
||
public Session(Long id, SessionImage sessionImage, SessionStatus sessionStatus, SessionDate sessionDate, Set<NsUser> students) { | ||
public Session(Long id, List<SessionImage> sessionImage, RecruitStatus recruitStatus, SessionProgressStatus sessionProgressStatus, SessionDate sessionDate, Set<NsUser> students, Set<NsUser> approveStudents) { | ||
this.id = id; | ||
this.sessionImage = sessionImage; | ||
this.sessionStatus = sessionStatus; | ||
this.recruitStatus = recruitStatus; | ||
this.sessionProgressStatus = sessionProgressStatus; | ||
this.sessionDate = sessionDate; | ||
this.students = students; | ||
this.approveStudents = approveStudents; | ||
|
||
} | ||
|
||
public final void enrollmentUser(NsUser user, Payment payment) { | ||
|
@@ -37,14 +48,22 @@ public final void enrollmentUser(NsUser user, Payment payment) { | |
students.add(user); | ||
} | ||
|
||
public final void removeNotApproveUser() { | ||
students.removeIf(student -> !approveStudents.contains(student)); | ||
} | ||
Comment on lines
+51
to
+53
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. 수강을 취소하더라도 신청 내역을 존재할 수 있을 것 같은데요 |
||
|
||
public final void addApproveStudent(NsUser nsUser) { | ||
approveStudents.add(nsUser); | ||
} | ||
|
||
private void assertNotDuplicateStudents(NsUser user) { | ||
if (students.contains(user)) { | ||
throw new NotRecruitException(); | ||
} | ||
} | ||
|
||
private void assertRecruit() { | ||
if (!sessionStatus.isRecruit()) { | ||
if (!recruitStatus.isRecruit()) { | ||
throw new NotRecruitException(); | ||
} | ||
} | ||
|
@@ -53,22 +72,34 @@ public Set<NsUser> getStudents() { | |
return new HashSet<>(students); | ||
} | ||
|
||
public Set<NsUser> getApproveStudents() { | ||
return new HashSet<>(approveStudents); | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public SessionImage getSessionImage() { | ||
public List<SessionImage> getSessionImage() { | ||
return sessionImage; | ||
} | ||
|
||
public SessionStatus getSessionStatus() { | ||
return sessionStatus; | ||
public RecruitStatus getRecruitStatus() { | ||
return recruitStatus; | ||
} | ||
|
||
public SessionProgressStatus getSessionProgressStatus() { | ||
return sessionProgressStatus; | ||
} | ||
|
||
public SessionDate getSessionDate() { | ||
return sessionDate; | ||
} | ||
|
||
public void changeProgressStatus(SessionProgressStatus sessionProgressStatus) { | ||
this.sessionProgressStatus = sessionProgressStatus; | ||
} | ||
|
||
|
||
abstract protected void assertSatisfiedCondition(NsUser user, Payment payment); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nextstep.courses.domain; | ||
|
||
public enum SessionProgressStatus { | ||
PREPARE, | ||
RUN, | ||
END; | ||
|
||
public static SessionProgressStatus findByName(String name) { | ||
return SessionProgressStatus.valueOf(name.toUpperCase()); | ||
} | ||
} |
This file was deleted.
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.
선발 과정이후 students, approveStudents 두 필드의 요소는 같을 것으로 예상됩니다.
두 가지를 모두 가지고 있을 필요가 있을까요?