-
Notifications
You must be signed in to change notification settings - Fork 298
3단계 - 수강신청(DB 적용) #642
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
Open
lee-won-suk
wants to merge
18
commits into
next-step:lee-won-suk
Choose a base branch
from
lee-won-suk:step3
base: lee-won-suk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
3단계 - 수강신청(DB 적용) #642
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
99ee29b
refactor: 코드리뷰 반영
b3f2ee9
chore: 패키지명 변경
9b3eae7
feat: sql문 작성 진행
cdd9531
feat: sql문 매핑 및 테스트 추가
aef0900
chore: README 수정
e006874
refactor: NamedParamegerJdbcTemplate를
3665cb3
refactor: 코드리뷰 개선
2396f22
refactor: 코드리뷰 개선
e32989a
feat: sessionid들을 가져오는 테이블 및 쿼리문 추가
lee-won-suk 14179e7
refactor: 코드리뷰 개선
6884466
Merge remote-tracking branch 'origin/step3' into step3
ad50fa7
refactor : course에 강의리스트 초기값 세팅 추가
0cc59c2
refactor : 과정과 강의를 N:M으로 매핑해주는 테이블 추가
4c6d5e6
refactor : 강의타입 enum으로 수정
abe6c31
refactor : 조회시 courseSessionRepository 사용하도록 수정 및 session 조회 같이 하도록 수정
4d99650
refactor : courseId와 courseType 반영
2473327
refactor : sql에 courseId와 courseType 반영
a3128b9
refactor : state enum에서 불필요한 이름 상태 동일한 것 수정
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 학습 관리 시스템(Learning Management System) | ||
|
||
## step3 요구사항 | ||
|
||
1. [x] 앞단계에서 구현한 도메인 모델 DB와 매핑하고 데이터 저장 | ||
2. | ||
2. 테이블 설계하고 객체매핑 | ||
2. [x] Payments는 테이블 매핑 미고려 | ||
|
||
## 관련 클래스 | ||
|
||
1. DB 테이블 resources/schema.sql | ||
2. jdbcCourseRepository | ||
3. CourseRepositoryTest | ||
|
||
|
||
## 주요 피드백 | ||
1. 숫자로 순서를 써서 하는건 실수 및 어려운 문제가 있음 | ||
-> NamedParameterJdbcTemplate사용해보기 | ||
|
||
|
||
TODO | ||
findSessions 메서드 테스트 코드 추가하기 |
20 changes: 0 additions & 20 deletions
20
src/main/java/nextstep/courses/Exception/ResponseType.java
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package nextstep.courses.domain; | ||
|
||
public enum CourseType { | ||
PREMIUM, BASIC; | ||
|
||
public static CourseType getCourseType(String courseType) { | ||
return CourseType.valueOf(courseType.toUpperCase()); | ||
} | ||
} | ||
|
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,35 +1,45 @@ | ||
package nextstep.courses.domain; | ||
|
||
import nextstep.courses.Exception.CustomException; | ||
import nextstep.courses.exception.CustomException; | ||
import nextstep.payments.domain.Payment; | ||
|
||
public class PricingType { | ||
|
||
private final int sessionAmount; | ||
private boolean isPremium; | ||
private final CourseType courseType; | ||
|
||
public PricingType(boolean isPremium, int sessionAmount) { | ||
validate(isPremium,sessionAmount); | ||
this.isPremium = isPremium; | ||
|
||
|
||
public PricingType(CourseType courseType, int sessionAmount) { | ||
this.courseType = courseType; | ||
this.sessionAmount = sessionAmount; | ||
validate(sessionAmount); | ||
} | ||
|
||
private void validate(boolean isPremium, int sessionAmount) { | ||
if (isPremium && sessionAmount <= 0) { | ||
private void validate(int sessionAmount) { | ||
if (isPremium() && sessionAmount <= 0) { | ||
throw CustomException.NOT_ALLOWED_PREMIUM_AMOUNT; | ||
} | ||
if (!isPremium && sessionAmount > 0) { | ||
if (!isPremium() && sessionAmount > 0) { | ||
throw CustomException.NOT_ALLOWED_FREE_AMOUNT; | ||
} | ||
} | ||
|
||
public boolean isPremium() { | ||
return isPremium; | ||
return courseType.equals(CourseType.PREMIUM); | ||
} | ||
|
||
public void validateAmount(Payment payment) { | ||
if (isPremium && !payment.matchingAmount(sessionAmount)) { | ||
if (isPremium() && !payment.matchingAmount(sessionAmount)) { | ||
throw CustomException.NOT_MATCHING_SESSION_AMOUNT; | ||
} | ||
} | ||
|
||
public int getSessionAmount() { | ||
return sessionAmount; | ||
} | ||
|
||
public CourseType getCourseType() { | ||
return courseType; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
package nextstep.courses.domain; | ||
|
||
public enum SessionState { | ||
READY("READY"), START("START"), END("END"); | ||
READY, START, END; | ||
|
||
|
||
public String state; | ||
|
||
SessionState(String state) { | ||
this.state = state; | ||
} | ||
|
||
public boolean isRequestSession() { | ||
return START.state.equals(this.state); | ||
return this == START; | ||
} | ||
} |
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
16 changes: 14 additions & 2 deletions
16
...ses/domain/sessionimage/SessionImage.java → ...ep/courses/domain/image/SessionImage.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,16 +1,28 @@ | ||
package nextstep.courses.domain.sessionimage; | ||
package nextstep.courses.domain.image; | ||
|
||
public class SessionImage { | ||
|
||
private final ImageCapacity capacity; | ||
private final ImageType type; | ||
private final ImageSize size; | ||
|
||
|
||
public SessionImage(ImageCapacity capacity, ImageType type, ImageSize size) { | ||
ImageType.validateType(type.name()); | ||
this.capacity = capacity; | ||
this.type = type; | ||
this.size = size; | ||
} | ||
|
||
public ImageCapacity getCapacity() { | ||
return capacity; | ||
} | ||
|
||
public ImageType getType() { | ||
return type; | ||
} | ||
|
||
public ImageSize getSize() { | ||
return size; | ||
} | ||
|
||
} |
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.
연관관계를 가지도록 매핑하셨네요
Course를 조회하는 시점에 같이 조회해야하지 않을까요?
따로 Session 리스트를 주입하는 부분을 찾을 수 없는 것 같아서요
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.
@nooose
안녕하세요 조회시 getSessions 메서드를 통해 같이 조회하도록 수정했습니다.