-
Notifications
You must be signed in to change notification settings - Fork 301
๐ 2๋จ๊ณ - ์๊ฐ์ ์ฒญ(๋๋ฉ์ธ ๋ชจ๋ธ) #796
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
Eundms
wants to merge
6
commits into
next-step:eundms
Choose a base branch
from
Eundms:step2
base: eundms
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.
+955
โ58
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1a6abb6
๐ 2๋จ๊ณ - ์๊ฐ์ ์ฒญ(๋๋ฉ์ธ ๋ชจ๋ธ) : TDD 1์ฐจ ๊ตฌํ
Eundms 4e163db
๐ 2๋จ๊ณ - ์๊ฐ์ ์ฒญ(๋๋ฉ์ธ ๋ชจ๋ธ) : id, enroll ๋ถ๋ฆฌ
Eundms fb2067e
ํจํค์ง ๋ถ๋ฆฌ, SessionType ๋ถ๋ฆฌ
Eundms 0e844d2
๋ฉ์๋๋ช
๋ณ๊ฒฝ ๋ฐ Registration ์ถ๊ฐ
Eundms 0786c0c
Enrollment ๋ถ๋ฆฌ, ๊ฐ๋ณ ๊ฐ์ฒดํ
Eundms a360bb3
payAmount long ํ์
์ผ๋ก ๋ณ๊ฒฝ
Eundms 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
File renamed without changes.
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,38 @@ | ||
| ## ์๊ฐ ์ ์ฒญ ๊ธฐ๋ฅ ์๊ตฌ์ฌํญ | ||
| - ๊ณผ์ (Course)์ ๊ธฐ์ ๋จ์๋ก ์ด์ํ๋ฉฐ, ์ฌ๋ฌ ๊ฐ์ ๊ฐ์(Session)๋ฅผ ๊ฐ์ง ์ ์๋ค. | ||
| - ๊ฐ์๋ ์์์ผ๊ณผ ์ข ๋ฃ์ผ์ ๊ฐ์ง๋ค. | ||
| - ๊ฐ์๋ ๊ฐ์ ์ปค๋ฒ ์ด๋ฏธ์ง ์ ๋ณด๋ฅผ ๊ฐ์ง๋ค. | ||
| - ์ด๋ฏธ์ง ํฌ๊ธฐ๋ 1MB ์ดํ์ฌ์ผ ํ๋ค. | ||
| - ์ด๋ฏธ์ง ํ์ ์ gif, jpg(jpeg ํฌํจ),, png, svg๋ง ํ์ฉํ๋ค. | ||
| - ์ด๋ฏธ์ง์ width๋ 300ํฝ์ , height๋ 200ํฝ์ ์ด์์ด์ด์ผ ํ๋ฉฐ, width์ height์ ๋น์จ์ 3:2์ฌ์ผ ํ๋ค. | ||
| - ๊ฐ์๋ ๋ฌด๋ฃ ๊ฐ์์ ์ ๋ฃ ๊ฐ์๋ก ๋๋๋ค. | ||
| - ๋ฌด๋ฃ ๊ฐ์๋ ์ต๋ ์๊ฐ ์ธ์ ์ ํ์ด ์๋ค. | ||
| - ์ ๋ฃ ๊ฐ์๋ ๊ฐ์ ์ต๋ ์๊ฐ ์ธ์์ ์ด๊ณผํ ์ ์๋ค. | ||
| - ์ ๋ฃ ๊ฐ์๋ ์๊ฐ์์ด ๊ฒฐ์ ํ ๊ธ์ก๊ณผ ์๊ฐ๋ฃ๊ฐ ์ผ์นํ ๋ ์๊ฐ ์ ์ฒญ์ด ๊ฐ๋ฅํ๋ค. | ||
| - ๊ฐ์ ์ํ๋ ์ค๋น์ค, ๋ชจ์ง์ค, ์ข ๋ฃ 3๊ฐ์ง ์ํ๋ฅผ ๊ฐ์ง๋ค. | ||
| - ๊ฐ์ ์๊ฐ์ ์ฒญ์ ๊ฐ์ ์ํ๊ฐ ๋ชจ์ง์ค์ผ ๋๋ง ๊ฐ๋ฅํ๋ค. | ||
| - ์ ๋ฃ ๊ฐ์์ ๊ฒฝ์ฐ ๊ฒฐ์ ๋ ์ด๋ฏธ ์๋ฃํ ๊ฒ์ผ๋ก ๊ฐ์ ํ๊ณ ์ดํ ๊ณผ์ ์ ๊ตฌํํ๋ค. | ||
| - ๊ฒฐ์ ๋ฅผ ์๋ฃํ ๊ฒฐ์ ์ ๋ณด๋ payments ๋ชจ๋์ ํตํด ๊ด๋ฆฌ๋๋ฉฐ, ๊ฒฐ์ ์ ๋ณด๋ Payment ๊ฐ์ฒด์ ๋ด๊ฒจ ๋ฐํ๋๋ค. | ||
|
|
||
|
|
||
| ## ํด๋์ค | ||
| - `๊ณผ์ (Course)` : 1 | ||
| - ๊ธฐ์ | ||
|
|
||
| - `๊ฐ์(Session)` : N | ||
| - ๊ธ์ก : ์ ๋ฃ / ๋ฌด๋ฃ | ||
| - ์ ๋ฃ ๊ฐ์ | ||
| - ๊ฐ์ ์ต๋ `์๊ฐ ์ธ์` ์ ํ | ||
| - `๊ฒฐ์ฌ ๊ธ์ก` = ์๊ฐ๋ฃ] | ||
| - ๋ฌด๋ฃ ๊ฐ์ | ||
| - ์ต๋ ์๊ฐ์ธ์ ์ ํ ์์ | ||
| - ์ํ : ์ค๋น์ค, ๋ชจ์ง์ค, ์ข ๋ฃ | ||
| - ์์์ผ, ์ข ๋ฃ์ผ | ||
| - ๊ฐ์ ์ปค๋ฒ ์ด๋ฏธ์ง | ||
|
|
||
| - `๊ฐ์ ์ปค๋ฒ ์ด๋ฏธ์ง (SessionCoverImage)` | ||
| - ํฌ๊ธฐ : 1MB | ||
| - ํ์ : gif, jpg(jpeg), png, svg | ||
| - dimension | ||
| - width >= 300, height >= 200 | ||
| - width : height = 3 : 2 |
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,36 @@ | ||
| package nextstep.courses.domain; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public abstract class BaseEntity { | ||
| private Long id; | ||
| private LocalDateTime createdAt; | ||
| private LocalDateTime updatedAt; | ||
|
|
||
| protected BaseEntity() { | ||
| this.createdAt = LocalDateTime.now(); | ||
| } | ||
|
|
||
| protected BaseEntity(Long id) { | ||
| this.id = id; | ||
| this.createdAt = LocalDateTime.now(); | ||
| } | ||
|
|
||
| protected BaseEntity(Long id, LocalDateTime createdAt, LocalDateTime updatedAt) { | ||
| this.id = id; | ||
| this.createdAt = createdAt; | ||
| this.updatedAt = updatedAt; | ||
| } | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public LocalDateTime getCreatedAt() { | ||
| return createdAt; | ||
| } | ||
|
|
||
| public LocalDateTime getUpdatedAt() { | ||
| return updatedAt; | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package nextstep.courses.domain.course; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.Objects; | ||
| import nextstep.courses.domain.BaseEntity; | ||
|
|
||
| public class Course extends BaseEntity { | ||
| private String title; | ||
| private Long creatorId; | ||
|
|
||
| public Course() { | ||
| } | ||
|
|
||
| public Course(String title, Long creatorId) { | ||
| this(null, title, creatorId); | ||
| } | ||
|
|
||
| public Course(Long id, String title, Long creatorId) { | ||
| super(id); | ||
| this.title = title; | ||
| this.creatorId = creatorId; | ||
| } | ||
|
|
||
| public Course(Long id, String title, Long creatorId, LocalDateTime createdAt, LocalDateTime updatedAt) { | ||
| super(id, createdAt, updatedAt); | ||
| this.title = title; | ||
| this.creatorId = creatorId; | ||
| } | ||
|
|
||
| public String getTitle() { | ||
| return title; | ||
| } | ||
|
|
||
| public Long getCreatorId() { | ||
| return creatorId; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Course{" + | ||
| "id=" + getId() + | ||
| ", title='" + title + '\'' + | ||
| ", creatorId=" + creatorId + | ||
| ", createdAt=" + getCreatedAt() + | ||
| '}'; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| Course course = (Course) o; | ||
| return Objects.equals(getId(), course.getId()); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hashCode(getId()); | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
...step/courses/domain/CourseRepository.java โ ...urses/domain/course/CourseRepository.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
17 changes: 17 additions & 0 deletions
17
src/main/java/nextstep/courses/domain/image/SessionCoverImage.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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package nextstep.courses.domain.image; | ||
|
|
||
| public class SessionCoverImage { | ||
| private final SessionImageDimension dimension; | ||
| private final SessionImageExtension extension; | ||
| private final SessionImageCapacity capacity; | ||
|
|
||
| public SessionCoverImage(int width, int height, String extension, long bytes) { | ||
| this(new SessionImageDimension(width, height), SessionImageExtension.from(extension), new SessionImageCapacity(bytes)); | ||
| } | ||
|
|
||
| public SessionCoverImage(SessionImageDimension dimension, SessionImageExtension extension, SessionImageCapacity capacity) { | ||
| this.dimension = dimension; | ||
| this.extension = extension; | ||
| this.capacity = capacity; | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/main/java/nextstep/courses/domain/image/SessionImageCapacity.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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package nextstep.courses.domain.image; | ||
|
|
||
| public class SessionImageCapacity { | ||
Eundms marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private static final long MAX_CAPACITY_BYTES = 1024 * 1024; // 1MB | ||
| private final long bytes; | ||
|
|
||
| public SessionImageCapacity(long bytes) { | ||
| validate(bytes); | ||
| this.bytes = bytes; | ||
| } | ||
|
|
||
| public static SessionImageCapacity ofKB(long kb) { | ||
| return new SessionImageCapacity(kb * 1024); | ||
| } | ||
|
|
||
| public static SessionImageCapacity ofMB(long mb) { | ||
| return new SessionImageCapacity(mb * 1024 * 1024); | ||
| } | ||
|
|
||
| private void validate(long bytes) { | ||
| if (bytes <= 0) { | ||
| throw new IllegalArgumentException("์ด๋ฏธ์ง ํฌ๊ธฐ๋ 0๋ณด๋ค ์ปค์ผ ํฉ๋๋ค."); | ||
| } | ||
| if (bytes > MAX_CAPACITY_BYTES) { | ||
| throw new IllegalArgumentException("์ด๋ฏธ์ง ํฌ๊ธฐ๋ 1MB ์ดํ์ฌ์ผ ํฉ๋๋ค."); | ||
| } | ||
| } | ||
|
|
||
| } | ||
38 changes: 38 additions & 0 deletions
38
src/main/java/nextstep/courses/domain/image/SessionImageDimension.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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package nextstep.courses.domain.image; | ||
|
|
||
| public class SessionImageDimension { | ||
| private static final int MIN_WIDTH = 300; | ||
| private static final int MIN_HEIGHT = 200; | ||
| private static final int RATIO_W = 3; | ||
| private static final int RATIO_H = 2; | ||
|
|
||
| private int width; | ||
| private int height; | ||
|
|
||
| public SessionImageDimension(int width, int height) { | ||
| validateMinLength(width, height); | ||
| validateRatio(width, height); | ||
| this.width = width; | ||
| this.height = height; | ||
| } | ||
| private void validateMinLength(int width, int height){ | ||
| if(!(width >= MIN_WIDTH && height >= MIN_HEIGHT)) { | ||
| throw new IllegalArgumentException("์ด๋ฏธ์ง๋ ๊ฐ๋ก 300์ด์, ์ธ๋ก 200 ์ด์์ด์ด์ผ ํฉ๋๋ค."); | ||
| } | ||
| } | ||
|
|
||
| private void validateRatio(int width, int height){ | ||
| int gcd = gcd(width, height); | ||
| int ratioW = width / gcd; | ||
| int ratioH = height / gcd; | ||
| if(!(ratioW == RATIO_W && ratioH == RATIO_H)){ | ||
| throw new IllegalArgumentException("์ด๋ฏธ์ง๋ ๊ฐ๋ก x ์ธ๋ก 3๋ 2์ด์ด์ผ ํฉ๋๋ค."); | ||
| } | ||
| } | ||
|
|
||
| private int gcd(int a, int b) { | ||
| return b == 0 ? a : gcd(b, a % b); | ||
| } | ||
|
|
||
|
|
||
| } |
27 changes: 27 additions & 0 deletions
27
src/main/java/nextstep/courses/domain/image/SessionImageExtension.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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package nextstep.courses.domain.image; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public enum SessionImageExtension { | ||
| GIF("gif"), | ||
| JPG("jpg", "jpeg"), | ||
| PNG("png"), | ||
| SVG("svg"); | ||
|
|
||
| private List<String> names; | ||
|
|
||
| SessionImageExtension(String... names){ | ||
| this.names = new ArrayList<>(List.of(names)); | ||
| } | ||
|
|
||
| public static SessionImageExtension from(String extension) { | ||
| String lowerExt = extension.toLowerCase(); | ||
| for (SessionImageExtension type : values()) { | ||
| if (type.names.contains(lowerExt)) { | ||
| return type; | ||
| } | ||
| } | ||
| throw new IllegalArgumentException("์ง์ํ์ง ์๋ ์ด๋ฏธ์ง ํ์ฅ์์ ๋๋ค: " + extension); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/nextstep/courses/domain/registration/Registration.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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package nextstep.courses.domain.registration; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public class Registration { | ||
| private final Long sessionId; | ||
| private final Long studentId; | ||
| private final LocalDateTime enrolledAt; | ||
|
|
||
| public Registration(Long sessionId, Long studentId) { | ||
| this(sessionId, studentId, LocalDateTime.now()); | ||
| } | ||
|
|
||
| public Registration(Long sessionId, Long studentId, LocalDateTime enrolledAt) { | ||
| this.sessionId = sessionId; | ||
| this.studentId = studentId; | ||
| this.enrolledAt = enrolledAt; | ||
| } | ||
| public boolean contains(Long studentId) { | ||
| return this.studentId == studentId; | ||
| } | ||
|
|
||
| } |
33 changes: 33 additions & 0 deletions
33
src/main/java/nextstep/courses/domain/registration/Registrations.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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package nextstep.courses.domain.registration; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| public class Registrations { | ||
| private final List<Registration> registrations; | ||
|
|
||
| public Registrations() { | ||
| this(new ArrayList<>()); | ||
| } | ||
|
|
||
| public Registrations(List<Registration> registrations) { | ||
| this.registrations = registrations; | ||
| } | ||
|
|
||
| public Registrations add(Registration registration) { | ||
| List<Registration> newList = new ArrayList<>(registrations); | ||
| newList.add(registration); | ||
| return new Registrations(newList); | ||
| } | ||
|
|
||
| public int count() { | ||
| return registrations.size(); | ||
| } | ||
|
|
||
| public boolean contains(Long studentId) { | ||
| return registrations.stream() | ||
| .anyMatch(r -> r.contains(studentId)); | ||
| } | ||
|
|
||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.