-
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
base: kimsunghyun1995
Are you sure you want to change the base?
Changes from 27 commits
fd5bc40
683b74c
bb4e0ee
c79a28c
b2e8b79
0ca406b
b0584e8
bec5bda
939744c
8de065d
611a834
5fef765
bbd2583
969a55e
9e4dbf2
de2692c
f1baa1e
b49e4f4
a7d6469
6b339bf
5a9ec82
885a682
f475bad
a446509
9e66e65
fad7a82
876b073
d17d14c
232fd52
9822a8c
04eef92
9262189
5e6f227
5811399
5c63ef1
627a90b
f0e800a
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,4 @@ | ||
package nextstep.session; | ||
|
||
public class NotFoundException extends RuntimeException { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
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, 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, SessionStatus sessionStatus, NsUsers nsUsers) { | ||
this.id = id; | ||
this.maximumNumberOfParticipants = maximumNumberOfParticipants; | ||
this.sessionPrice = sessionPrice; | ||
this.sessionStatus = sessionStatus; | ||
this.nsUsers = 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("๊ฐ์๊ฐ ์ค๋น์ค์ด ์๋๋๋ค."); | ||
} | ||
Comment on lines
+33
to
+35
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. ๋ฉ์๋ ์ด๋ฆ์ ์๊ฐ ์ ์ฒญ ๊ฐ๋ฅ ๊ธฐ๊ฐ์์ ๋ฌผ์ด๋ณด๊ณ ์๋๋ฐ ์์ธ์ฒ๋ฆฌ๋ฅผ ํ๋ ๊ฒ์ ๋ญ๊ฐ ์ด์ํจ |
||
return true; | ||
} | ||
|
||
private boolean isParticipantsSession() { | ||
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() && isParticipantsSession(); | ||
} | ||
|
||
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 ๊ฐ์ฒด ๋์ถํ ์ ๐ |
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.
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 + | ||
'}'; | ||
} | ||
|
||
} |
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 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.
๋ถ ์์ฑ์๊ฐ ์ฃผ ์์ฑ์๋ฅผ ํธ์ถํ๋๋ก ๊ตฌํ