-
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
๐ 3๋จ๊ณ - ์๊ฐ์ ์ฒญ(DB ์ ์ฉ) #531
Open
kimsunghyun1995
wants to merge
37
commits into
next-step:kimsunghyun1995
Choose a base branch
from
kimsunghyun1995:step3
base: kimsunghyun1995
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
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
fd5bc40
doc: step3 ์๊ตฌ์ฌํญ ์ ๋ฆฌ
kimsunghyun1995 683b74c
feat: ์๊ฐ์ ์ฒญ๋ง์ ์ํ ํด๋์ค Enrollment ์ถ๊ฐ
kimsunghyun1995 bb4e0ee
feat: imageInfo ํ
์ด๋ธ ๋งคํ ๋ฐ CRUD ๊ธฐ๋ฅ ๊ตฌํ
kimsunghyun1995 c79a28c
feat: ์ฟผ๋ฆฌ ์ฌ์ฉ์ ์ํ Getter ์ถ๊ฐ
kimsunghyun1995 b2e8b79
feat: image_info DDL ๋ฐ ์์๋ฐ์ดํฐ ์ถ๊ฐ
kimsunghyun1995 0ca406b
test: imageInfo Repository ํ
์คํธ ์ฝ๋ ์ถ๊ฐ
kimsunghyun1995 b0584e8
refactor: ์ฌ์ฉํ์ง ์๋ ํจํค์ง ์ ๋ฆฌ
kimsunghyun1995 bec5bda
doc: ํด๋์ค DB ๋งคํ ์ ๋ณด ์์
kimsunghyun1995 939744c
refactor: ์๊ฐ์ ์ฒญ ๊ธ์ก๋ Session -> Enrollment๋ก ์ด๋
kimsunghyun1995 8de065d
feat: enrollment repository ์ถ๊ฐ
kimsunghyun1995 611a834
feat: nsUser ํ
์ด๋ธ ํ๋ ์ถ๊ฐ ๋ฐ ๋ฐ์ดํฐ ์ถ๊ฐ
kimsunghyun1995 5fef765
feat: nsUser์ session_id ํ๋ ์ถ๊ฐ ๋ฐ findallBySessionId ์ฟผ๋ฆฌ ์ถ๊ฐ
kimsunghyun1995 bbd2583
test: findAllBySessionId ๋ฉ์๋ ํ
์คํธ ์ถ๊ฐ
kimsunghyun1995 969a55e
fix: ๋ฐ์ดํฐ ์์
kimsunghyun1995 9e4dbf2
refactor: ์ฌ์ฉํ์ง ์๋ import ์ ๋ฆฌ ๋ฐ final ์ถ๊ฐ
kimsunghyun1995 de2692c
feat: EnrollRepository ๊ธฐ๋ฅ ๊ตฌํ
kimsunghyun1995 f1baa1e
test: EnrollmentRepository ํ
์คํธ
kimsunghyun1995 b49e4f4
feat: ์ฟผ๋ฆฌ ์ฌ์ฉ์ ์ํ getter ์ถ๊ฐ
kimsunghyun1995 a7d6469
feat: session๊ณผ ์ฐ๊ด๊ด๊ณ๋ฅผ ์ํ sessionId ํ๋ ์ถ๊ฐ
kimsunghyun1995 6b339bf
fix: mapper ์ฌ์ฉ์ ์ํ ์ถ์ ํด๋์ค ์ญ์
kimsunghyun1995 5a9ec82
refactor: sessionId ํ๋ ์ถ๊ฐ๋ก ์ธํ ํ
์คํธ ์ฝ๋ ์์
kimsunghyun1995 885a682
doc: ์งํ์ํฉ ์ ๋ฆฌ
kimsunghyun1995 f475bad
feat: session ํ
์ด๋ธ ๋ฐ ๋ฐ์ดํฐ ์์ฑ
kimsunghyun1995 a446509
feat: session ๋ฐ์ดํฐ๋ฅผ ์ํ enroll๊ณผ iamgeinfo ๋ฐ์ดํฐ sessionId๋ก ๊ฐ์ ธ์ค๋ ๊ธฐ๋ฅ ๊ตฌํ
kimsunghyun1995 9e66e65
feat: notFound ์ต์
์
์ถ๊ฐ
kimsunghyun1995 fad7a82
feat: sessionRepository ๊ตฌํ์ฒด ๊ตฌํ
kimsunghyun1995 876b073
test: sessionRepository ํ
์คํธ ์ถ๊ฐ
kimsunghyun1995 d17d14c
refactor: ๋ถ ์์ฑ์๊ฐ ์ฃผ ์์ฑ์ ํธ์ถํ๋๋ก ์ฝ๋ ์ ๋ฆฌ
kimsunghyun1995 232fd52
refactor: ์๊ฐ์ ์ฒญ ์ธ์์ ๋ํ ํ์ธ ๋ฉ์๋ ๋ค์ด๋ฐ ๋ณ๊ฒฝ
kimsunghyun1995 9822a8c
feature: NsUser : Session์ ๊ด๊ณ(M:N)์ ๋ํด ์๋ก์ด ๋๋ฉ์ธ ์์ฑ
kimsunghyun1995 04eef92
feature: student_enrollment_information db ๋ฐ์ดํฐ ์์ฑ
kimsunghyun1995 9262189
fix: ๊ธฐ์กด M:N ๊ด๊ณ ๋๋ฉ์ธ ์์
kimsunghyun1995 5e6f227
fix: studentEnrollmentInformation ๋๋ฉ์ธ ์์ฑ์ผ๋ก ์ธํ repository ์์
kimsunghyun1995 5811399
feat: User ๋๋ฉ์ธ์ ๋ณต์๊ฐ id๋ก ์กฐํํ๋ in ์ฟผ๋ฆฌ ์ถ๊ฐ
kimsunghyun1995 5c63ef1
test: ๋ณต์๊ฐ์ ID๋ก ์กฐํํ๋ ์ฟผ๋ฆฌ ํ
์คํธ
kimsunghyun1995 627a90b
test: ์์กด์ฑ ์ถ๊ฐ
kimsunghyun1995 f0e800a
fix: enrollment์ User ๋ฆฌ์คํธ ์์ฑํ๋ ๋ถ๋ถ ์ถ๊ฐ
kimsunghyun1995 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 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 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,4 @@ | ||
package nextstep.session; | ||
|
||
public class NotFoundException extends RuntimeException { | ||
} |
This file contains 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,96 @@ | ||
package nextstep.session.domain; | ||
|
||
import nextstep.users.domain.NsUser; | ||
import nextstep.users.domain.NsUsers; | ||
|
||
public class Enrollment { | ||
private static final int INCREASE_STUDENT = 1; | ||
private long id; | ||
private final int maximumNumberOfParticipants; | ||
private final long sessionPrice; | ||
private long sessionId; | ||
private SessionStatus sessionStatus; | ||
private NsUsers nsUsers; | ||
|
||
public Enrollment(int maximumNumberOfParticipants, long sessionPrice) { | ||
this(0L, maximumNumberOfParticipants, sessionPrice, 0L, SessionStatus.PREPARING, new NsUsers()); | ||
} | ||
|
||
public Enrollment(long id, int maximumNumberOfParticipants, long sessionPrice, long sessionId) { | ||
this(id, maximumNumberOfParticipants, sessionPrice, sessionId, SessionStatus.PREPARING, new NsUsers()); | ||
} | ||
|
||
public Enrollment(long id, int maximumNumberOfParticipants, long sessionPrice, long sessionId, SessionStatus sessionStatus, NsUsers nsUsers) { | ||
this.id = id; | ||
this.maximumNumberOfParticipants = maximumNumberOfParticipants; | ||
this.sessionPrice = sessionPrice; | ||
this.sessionId = sessionId; | ||
this.sessionStatus = sessionStatus; | ||
this.nsUsers = nsUsers; | ||
} | ||
|
||
private boolean isSessionRegister() { | ||
if (sessionStatus != SessionStatus.PREPARING) { | ||
throw new IllegalArgumentException("๊ฐ์๊ฐ ์ค๋น์ค์ด ์๋๋๋ค."); | ||
} | ||
return true; | ||
} | ||
|
||
private boolean validateParticipantsLimit() { | ||
if (maximumNumberOfParticipants < nsUsers.getNumberOfStudent() + INCREASE_STUDENT) { | ||
throw new IllegalArgumentException("์๊ฐ์ธ์์ด ์ด๊ณผ๋์์ต๋๋ค."); | ||
} | ||
return true; | ||
} | ||
|
||
public boolean isMaximumNumberOfParticipantsLimited(int numberOfParticipants) { | ||
return numberOfParticipants <= maximumNumberOfParticipants; | ||
} | ||
|
||
public boolean isSamePaymentAndSessionPrice(int payment) { | ||
return payment == sessionPrice; | ||
} | ||
|
||
|
||
private boolean isAddStudent() { | ||
return isSessionRegister() && validateParticipantsLimit(); | ||
} | ||
|
||
public void applySession(NsUser student) { | ||
if (isAddStudent()) { | ||
nsUsers.addStudent(student); | ||
} | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public int getMaximumNumberOfParticipants() { | ||
return maximumNumberOfParticipants; | ||
} | ||
|
||
public int getSessionStatus() { | ||
return sessionStatus.getStatusValue(); | ||
} | ||
|
||
public long getSessionPrice() { | ||
return sessionPrice; | ||
} | ||
|
||
public long getSessionId() { | ||
return sessionId; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Enrollment{" + | ||
"id=" + id + | ||
", maximumNumberOfParticipants=" + maximumNumberOfParticipants + | ||
", sessionPrice=" + sessionPrice + | ||
", sessionStatus=" + sessionStatus + | ||
", nsUsers=" + nsUsers + | ||
'}'; | ||
} | ||
|
||
} | ||
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. Enrollment ๊ฐ์ฒด ๋์ถํ ์ ๐ |
12 changes: 12 additions & 0 deletions
12
src/main/java/nextstep/session/domain/EnrollmentRepository.java
This file contains 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,12 @@ | ||
package nextstep.session.domain; | ||
|
||
import java.util.Optional; | ||
|
||
public interface EnrollmentRepository { | ||
int save(Enrollment enrollment); | ||
Optional<Enrollment> findById(long id); | ||
int update(Enrollment enrollment); | ||
int deleteById(long id); | ||
Optional<Enrollment> findBySessionId(long id); | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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,18 +1,63 @@ | ||
package nextstep.session.domain; | ||
|
||
public class ImageInfo { | ||
private long id; | ||
private ImageSize imageSize; | ||
private ImageReSolution imageReSolution; | ||
private ImageType imageType; | ||
private long sessionId; | ||
|
||
public ImageInfo(String type) { | ||
this(null, null, ImageType.getImageType(type)); | ||
this(0L, null, null, ImageType.getImageType(type)); | ||
} | ||
|
||
public ImageInfo(ImageSize imageSize, ImageReSolution imageReSolution, ImageType imageType) { | ||
public ImageInfo(long id, ImageSize imageSize, ImageReSolution imageReSolution, ImageType imageType) { | ||
this.id = id; | ||
this.imageSize = imageSize; | ||
this.imageReSolution = imageReSolution; | ||
this.imageType = imageType; | ||
} | ||
|
||
public ImageInfo(long id, ImageSize imageSize, ImageReSolution imageReSolution, ImageType imageType, long sessionId) { | ||
this.id = id; | ||
this.imageSize = imageSize; | ||
this.imageReSolution = imageReSolution; | ||
this.imageType = imageType; | ||
this.sessionId = sessionId; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public int getImageSize() { | ||
return imageSize.getImageSize(); | ||
} | ||
|
||
public int getImageHeight() { | ||
return imageReSolution.getHeight(); | ||
} | ||
|
||
public int getImageWidth() { | ||
return imageReSolution.getWidth(); | ||
} | ||
|
||
public String getImageType() { | ||
return imageType.name(); | ||
} | ||
|
||
public long getSessionId() { | ||
return sessionId; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ImageInfo{" + | ||
"id=" + id + | ||
", imageSize=" + imageSize + | ||
", imageReSolution=" + imageReSolution + | ||
", imageType=" + imageType + | ||
'}'; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/nextstep/session/domain/ImageInfoRepository.java
This file contains 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,16 @@ | ||
package nextstep.session.domain; | ||
|
||
import java.util.Optional; | ||
|
||
public interface ImageInfoRepository { | ||
int save(ImageInfo imageInfo); | ||
|
||
Optional<ImageInfo> findById(long id); | ||
|
||
Optional<ImageInfo> findBySessionId(long sessionId); | ||
|
||
int update(ImageInfo imageInfo); | ||
|
||
int deleteById(long id); | ||
|
||
} |
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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
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.
๋ฉ์๋ ์ด๋ฆ์ ์๊ฐ ์ ์ฒญ ๊ฐ๋ฅ ๊ธฐ๊ฐ์์ ๋ฌผ์ด๋ณด๊ณ ์๋๋ฐ ์์ธ์ฒ๋ฆฌ๋ฅผ ํ๋ ๊ฒ์ ๋ญ๊ฐ ์ด์ํจ
์๋์ ์๋ isParticipantsSession() ๋ฉ์๋๋ ๊ฐ๋ค.
๋ฉ์๋ ์ด๋ฆ์ ๋ฐ๊พธ๊ฑฐ๋ ์์ธ ์ฒ๋ฆฌ๋ฅผ ์์ ๋๊ฐ ์ ํํ๋ฉด ์ด๋จ๊น?