-
Notifications
You must be signed in to change notification settings - Fork 248
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
재성님 안녕하세요! lms 마지막 요구사항 변경 부분 진행해봤습니다! #396
base: jhd7130
Are you sure you want to change the base?
Changes from 9 commits
ff5e7b6
d918b0c
96d1b01
04fade3
2c000d7
1cbd539
02ee984
0ac6372
7c5e351
088f5dd
6838fca
ebbc440
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,35 @@ | ||
package nextstep.courses.domain.coverimage; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class CoverImages { | ||
|
||
private Set<CoverImage> coverImages = new HashSet<>(); | ||
|
||
public CoverImages() { | ||
} | ||
|
||
public CoverImages(Set<CoverImage> coverImages) { | ||
this.coverImages = coverImages; | ||
} | ||
public CoverImages(CoverImage coverImages) { | ||
this.coverImages.add(coverImages); | ||
} | ||
|
||
public void add(CoverImage coverImage) { | ||
this.coverImages.add(coverImage); | ||
} | ||
public void addAll(CoverImages coverImages) { | ||
this.coverImages.addAll(coverImages.coverImages); | ||
} | ||
|
||
public boolean has(CoverImage coverImage) { | ||
return this.coverImages.contains(coverImage); | ||
} | ||
public List<CoverImage> coverImages() { | ||
return new ArrayList<>(coverImages); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package nextstep.courses.domain.coverimage; | ||
|
||
import nextstep.courses.domain.lectures.LectureEntity; | ||
|
||
public interface LectureCoverImageMappingRepository { | ||
void save(LectureEntity lecture, CoverImages coverImages); | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,42 +4,64 @@ | |||||
import nextstep.courses.BaseTime; | ||||||
import nextstep.courses.domain.coverimage.CoverImage; | ||||||
import nextstep.courses.domain.Students; | ||||||
import nextstep.courses.domain.coverimage.CoverImages; | ||||||
import nextstep.users.domain.NsUser; | ||||||
|
||||||
public class FreeLecture extends BaseTime implements Lecture { | ||||||
|
||||||
private final LectureType lectureType = LectureType.FREE; | ||||||
private final Long id; | ||||||
private final String title; | ||||||
private final CoverImage coverImage; | ||||||
private final CoverImages coverImages = new CoverImages(); | ||||||
private final LectureStatus lectureStatus; | ||||||
private final LectureRecruitingStatus lectureRecruitingStatus; | ||||||
private final RegistrationPeriod registrationPeriod; | ||||||
private final Students students = Students.defaultOf(); // 강의 기본정보와는 다름 | ||||||
|
||||||
public FreeLecture(Long id, String title, CoverImage coverImage, LectureStatus lectureStatus, | ||||||
public FreeLecture(Long id, String title, CoverImages coverImages, | ||||||
LectureRecruitingStatus lectureRecruitingStatus, | ||||||
RegistrationPeriod registrationPeriod) { | ||||||
super(); | ||||||
this.id = id; | ||||||
this.title = title; | ||||||
this.coverImages.addAll(coverImages); | ||||||
this.lectureStatus = LectureStatus.YET; | ||||||
this.lectureRecruitingStatus = lectureRecruitingStatus; | ||||||
this.registrationPeriod = registrationPeriod; | ||||||
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 FreeLecture(Long id, String title, CoverImages coverImages, LectureStatus lectureStatus, | ||||||
LectureRecruitingStatus lectureRecruitingStatus, | ||||||
RegistrationPeriod registrationPeriod) { | ||||||
super(); | ||||||
this.id = id; | ||||||
this.title = title; | ||||||
this.coverImage = coverImage; | ||||||
this.coverImages.addAll(coverImages); | ||||||
this.lectureStatus = lectureStatus; | ||||||
this.lectureRecruitingStatus = lectureRecruitingStatus; | ||||||
this.registrationPeriod = registrationPeriod; | ||||||
} | ||||||
|
||||||
public FreeLecture(Long id, String title, CoverImage coverImage, LectureStatus lectureStatus, | ||||||
LectureRecruitingStatus lectureRecruitingStatus, | ||||||
RegistrationPeriod registrationPeriod, LocalDateTime createdAt, LocalDateTime updatedAt) { | ||||||
super(createdAt, updatedAt); | ||||||
this.id = id; | ||||||
this.title = title; | ||||||
this.coverImage = coverImage; | ||||||
this.coverImages.add(coverImage); | ||||||
this.lectureStatus = lectureStatus; | ||||||
this.lectureRecruitingStatus = lectureRecruitingStatus; | ||||||
this.registrationPeriod = registrationPeriod; | ||||||
} | ||||||
|
||||||
public FreeLecture(LectureEntity lecture) { | ||||||
super(lecture.getCreatedAt(), lecture.getUpdatedAt()); | ||||||
this.id = lecture.getId(); | ||||||
this.title = lecture.getTitle(); | ||||||
this.coverImage = lecture.getCoverImage(); | ||||||
this.lectureStatus = lecture.getLectureStatus(); | ||||||
this.registrationPeriod = lecture.getRegistrationPeriod(); | ||||||
this.id = lecture.id(); | ||||||
this.title = lecture.title(); | ||||||
this.coverImages.addAll(lecture.coverImage()); | ||||||
this.lectureStatus = lecture.lectureStatus(); | ||||||
this.lectureRecruitingStatus = lecture.lectureRecruitingStatus(); | ||||||
this.registrationPeriod = lecture.registrationPeriod(); | ||||||
} | ||||||
|
||||||
@Override | ||||||
|
@@ -48,35 +70,53 @@ public boolean isFree() { | |||||
} | ||||||
|
||||||
@Override | ||||||
public boolean recruiting() { | ||||||
return LectureStatus.RECRUITING.equals(this.lectureStatus); | ||||||
public boolean isRecruiting() { | ||||||
return LectureRecruitingStatus.RECRUITING.equals(this.lectureRecruitingStatus); | ||||||
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.
Suggested change
enum 또한 객체라 메시지를 보내 구현 가능함 |
||||||
} | ||||||
|
||||||
@Override | ||||||
public void enrollment(NsUser nsUser) { | ||||||
if (recruiting()) { | ||||||
public void canEnrollment(NsUser nsUser, Students selectedStudents) { | ||||||
if (!isRecruiting()) { | ||||||
throw new IllegalArgumentException("모집중이지 않습니다."); | ||||||
} | ||||||
students.add(nsUser); | ||||||
|
||||||
if (selectedStudents.contain(nsUser)) { | ||||||
throw new IllegalArgumentException("선발된 인원만 수강신청이 가능합니다."); | ||||||
} | ||||||
} | ||||||
|
||||||
@Override | ||||||
public void enrollment(NsUser nsUser, Students selectedStudents) { | ||||||
this.canEnrollment(nsUser,selectedStudents); | ||||||
this.students.add(nsUser); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public Lecture recruitingStart() { | ||||||
return new FreeLecture(this.id, this.title, this.coverImages, | ||||||
LectureRecruitingStatus.RECRUITING, this.registrationPeriod); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public Lecture start() { | ||||||
return new FreeLecture(this.id, this.title, this.coverImage, LectureStatus.RECRUITING, this.registrationPeriod); | ||||||
return new FreeLecture(this.id, this.title, this.coverImages, LectureStatus.DOING, | ||||||
LectureRecruitingStatus.RECRUITING, this.registrationPeriod); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public Integer numberOfStudent() { | ||||||
return students.size(); | ||||||
} | ||||||
|
||||||
|
||||||
public LectureEntity toEntity() { | ||||||
return new LectureEntity( | ||||||
this.id | ||||||
, this.title | ||||||
, this.coverImage | ||||||
, this.coverImages | ||||||
, this.lectureType | ||||||
, this.lectureStatus | ||||||
, this.lectureRecruitingStatus | ||||||
, this.registrationPeriod | ||||||
, null | ||||||
, null | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
package nextstep.courses.domain.lectures; | ||
|
||
import nextstep.courses.domain.Students; | ||
import nextstep.users.domain.NsUser; | ||
|
||
public interface Lecture { | ||
|
||
boolean isFree(); | ||
boolean recruiting(); | ||
void enrollment(NsUser nsUser); | ||
boolean isRecruiting(); | ||
void canEnrollment(NsUser nsUser, Students selectedStudents); | ||
void enrollment(NsUser nsUser, Students selectedStudents); | ||
Lecture recruitingStart(); | ||
Lecture start(); | ||
Integer numberOfStudent(); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||||||||||||||||||
package nextstep.courses.domain.lectures; | ||||||||||||||||||||
|
||||||||||||||||||||
public enum LectureRecruitingStatus { | ||||||||||||||||||||
RECRUITING("RECRUITING") | ||||||||||||||||||||
, CLOSING("CLOSING") | ||||||||||||||||||||
, PREPARING("PREPARING") | ||||||||||||||||||||
, NO_MATCH("NO_MATCH") | ||||||||||||||||||||
; | ||||||||||||||||||||
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.
Suggested change
위와 같이 스타일로 구현하는 것도 가능함 |
||||||||||||||||||||
private final String name; | ||||||||||||||||||||
|
||||||||||||||||||||
LectureRecruitingStatus(String name) { | ||||||||||||||||||||
this.name = name; | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
public String getName() { | ||||||||||||||||||||
return name; | ||||||||||||||||||||
} | ||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,7 @@ | ||
package nextstep.courses.domain.lectures; | ||
|
||
public enum LectureStatus { | ||
RECRUITING("RECRUITING") | ||
, CLOSING("CLOSING") | ||
, PREPARING("PREPARING") | ||
, NO_MATCH("NO_MATCH") | ||
; | ||
private final String name; | ||
|
||
LectureStatus(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
DOING | ||
, YET | ||
, DONE | ||
} |
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.
👍