Skip to content
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

๐Ÿš€ 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ(๋„๋ฉ”์ธ ๋ชจ๋ธ) #627

Open
wants to merge 23 commits into
base: mingulee-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f89ccf9
refactor: 1๋‹จ๊ณ„ ํ”ผ๋“œ๋ฐฑ ๋ฐ˜์˜ - ๋ถˆํ•„์š” setDeleted ์‚ฌ์šฉ ์ œ๊ฑฐ
mingulee-devel Oct 28, 2024
372331e
refactor: 1๋‹จ๊ณ„ ํ”ผ๋“œ๋ฐฑ ๋ฐ˜์˜ - DeleteHistory ์ƒ์„ฑ์ž๊ฐ€ ์•„๋‹Œ ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ๋กœ ์ƒ์„ฑํ•˜๋„๋ก ์ˆ˜์ •
mingulee-devel Oct 28, 2024
8928f60
chore: ๋ถˆํ•„์š” ์ฝ”๋“œ ์‚ญ์ œ
mingulee-devel Oct 28, 2024
d965af3
docs: ๋ถˆํ•„์š” TODO ์‚ญ์ œ
mingulee-devel Oct 28, 2024
a22f18e
refactor: 1๋‹จ๊ณ„ ํ”ผ๋“œ๋ฐฑ ๋ฐ˜์˜ - Answers ์ผ๊ธ‰์ปฌ๋ ‰์…˜ ๋ถ„๋ฆฌ, ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜์ •
mingulee-devel Oct 28, 2024
e9340bd
refactor: QuestionBody ๋ถ„๋ฆฌ
mingulee-devel Oct 30, 2024
1ec08ae
refactor: Deleted ๋ถ„๋ฆฌ
mingulee-devel Oct 30, 2024
f320b7b
docs: 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ TODO ์ž‘์„ฑ
mingulee-devel Oct 30, 2024
e379e60
feat: 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ ๊ฐ•์˜ ์ƒํƒœ ๋„๋ฉ”์ธ ๊ตฌํ˜„
mingulee-devel Oct 30, 2024
8311e79
test: 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ ๊ฐ•์˜ ๋„๋ฉ”์ธ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
mingulee-devel Oct 30, 2024
c3837de
test: 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ ๊ฐ•์˜ ์ปค๋ฒ„ ์ด๋ฏธ์ง€ ๋„๋ฉ”์ธ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
mingulee-devel Oct 30, 2024
6a0964e
feat: 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ ๊ฐ•์˜ ์ปค๋ฒ„ ์ด๋ฏธ์ง€ ๋„๋ฉ”์ธ ๊ตฌํ˜„
mingulee-devel Oct 30, 2024
bcae477
feat: 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ ๊ฐ•์˜ ํ…Œ์ŠคํŠธ์ฝ”๋“œ ๋ฐ ๋„๋ฉ”์ธ ๊ตฌํ˜„
mingulee-devel Oct 30, 2024
dcea385
feat: 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ ๊ฐ•์˜ ์œ ๋ฃŒ๊ฐ•์˜ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ถ”๊ฐ€
mingulee-devel Oct 30, 2024
3423226
feat: 2๋‹จ๊ณ„ - ์ˆ˜๊ฐ•์‹ ์ฒญ ์ฝ”์Šค์— ๊ฐ•์˜ ๋ฆฌ์ŠคํŠธ ์ถ”๊ฐ€
mingulee-devel Oct 31, 2024
2a43351
feat: 2๋‹จ๊ณ„ - Course ๊ธฐ์ˆ˜ ์ถ”๊ฐ€
mingulee-devel Oct 31, 2024
82675be
feat: 2๋‹จ๊ณ„ - SessionStrategy ์ˆ˜์ •, PaidSession List<Payment> ์ถ”๊ฐ€
mingulee-devel Oct 31, 2024
f787e17
feat: 2๋‹จ๊ณ„ - Payments ์ผ๊ธ‰์ปฌ๋ ‰์…˜ ๋ถ„๋ฆฌ
mingulee-devel Oct 31, 2024
26e958f
feat: 2๋‹จ๊ณ„ - Sessions ์ผ๊ธ‰์ปฌ๋ ‰์…˜ ๋ถ„๋ฆฌ
mingulee-devel Oct 31, 2024
cf83180
feat: 2๋‹จ๊ณ„ - SessionDate ๋ถ„๋ฆฌ
mingulee-devel Oct 31, 2024
6355517
feat: 2๋‹จ๊ณ„ - session ํŒจํ‚ค์ง€ ์ถ”๊ฐ€, Payments payments ํŒจํ‚ค์ง€๋กœ ํŒŒ์ผ ์ด๋™
mingulee-devel Oct 31, 2024
786f774
feat: 2๋‹จ๊ณ„ - ImageExtension(Enum), ImageSize, ImageDimensions ๋ถ„๋ฆฌ
mingulee-devel Oct 31, 2024
950b4a8
refeactor: 2๋‹จ๊ณ„ ํ”ผ๋“œ๋ฐฑ ๋ฐ˜์˜ - ์œ ํšจํ•œ ํ™•์žฅ์ž ์ƒ์ˆ˜๋กœ ๋ถ„๋ฆฌ
mingulee-devel Nov 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,63 @@ Question
- [x] answer์— ๋‹ค๋ฅธ ์‚ฌ๋žŒ ๋‹ต๋ณ€์ด ์žˆ๋Š” ๊ฒฝ์šฐ
- [x] ์งˆ๋ฌธ ์‚ญ์ œ
- [x] ์งˆ๋ฌธ ์‚ญ์ œ
- [ ] ์งˆ๋ฌธ ์‚ญ์ œ ์ด๋ ฅ ๊ธฐ๋ก
- [ ] ๋ชจ๋“  ๋‹ต๋ณ€ ์‚ญ์ œ

Answer
- [x] ์ž‘์„ฑ์ž ๋ณธ์ธ์ธ์ง€ ํ™•์ธ
- [x] ๋‹ต๋ณ€ ์‚ญ์ œ
- [x] ๋‹ต๋ณ€ ์‚ญ์ œ
- [ ] ๋‹ต๋ณ€ ์‚ญ์ œ ์ด๋ ฅ ๊ธฐ๋ก

---

### ์ˆ˜๊ฐ• ์‹ ์ฒญ ๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ
- [x] ๊ณผ์ •(Course)์€ ๊ธฐ์ˆ˜ ๋‹จ์œ„๋กœ ์šด์˜ํ•˜๋ฉฐ, ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๊ฐ•์˜(Session)๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.
- [x] ๊ฐ•์˜๋Š” ์‹œ์ž‘์ผ๊ณผ ์ข…๋ฃŒ์ผ์„ ๊ฐ€์ง„๋‹ค.
- [x] ๊ฐ•์˜๋Š” ๊ฐ•์˜ ์ปค๋ฒ„ ์ด๋ฏธ์ง€ ์ •๋ณด๋ฅผ ๊ฐ€์ง„๋‹ค.
- [x] ์ด๋ฏธ์ง€ ํฌ๊ธฐ๋Š” 1MB ์ดํ•˜์—ฌ์•ผ ํ•œ๋‹ค.
- [x] ์ด๋ฏธ์ง€ ํƒ€์ž…์€ gif, jpg(jpeg ํฌํ•จ), png, svg๋งŒ ํ—ˆ์šฉํ•œ๋‹ค.
- [x] ์ด๋ฏธ์ง€์˜ width๋Š” 300ํ”ฝ์…€, height๋Š” 200ํ”ฝ์…€ ์ด์ƒ์ด์–ด์•ผ ํ•˜๋ฉฐ, width์™€ height์˜ ๋น„์œจ์€ 3:2์—ฌ์•ผ ํ•œ๋‹ค.
- [x] ๊ฐ•์˜๋Š” ๋ฌด๋ฃŒ ๊ฐ•์˜์™€ ์œ ๋ฃŒ ๊ฐ•์˜๋กœ ๋‚˜๋‰œ๋‹ค.
- [x] ๋ฌด๋ฃŒ ๊ฐ•์˜๋Š” ์ตœ๋Œ€ ์ˆ˜๊ฐ• ์ธ์› ์ œํ•œ์ด ์—†๋‹ค.
- [x] ์œ ๋ฃŒ ๊ฐ•์˜๋Š” ๊ฐ•์˜ ์ตœ๋Œ€ ์ˆ˜๊ฐ• ์ธ์›์„ ์ดˆ๊ณผํ•  ์ˆ˜ ์—†๋‹ค.
- [x] ์œ ๋ฃŒ ๊ฐ•์˜๋Š” ์ˆ˜๊ฐ•์ƒ์ด ๊ฒฐ์ œํ•œ ๊ธˆ์•ก๊ณผ ์ˆ˜๊ฐ•๋ฃŒ๊ฐ€ ์ผ์น˜ํ•  ๋•Œ ์ˆ˜๊ฐ• ์‹ ์ฒญ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
- [x] ๊ฐ•์˜ ์ƒํƒœ๋Š” ์ค€๋น„์ค‘, ๋ชจ์ง‘์ค‘, ์ข…๋ฃŒ 3๊ฐ€์ง€ ์ƒํƒœ๋ฅผ ๊ฐ€์ง„๋‹ค.
- [x] ๊ฐ•์˜ ์ˆ˜๊ฐ•์‹ ์ฒญ์€ ๊ฐ•์˜ ์ƒํƒœ๊ฐ€ ๋ชจ์ง‘์ค‘์ผ ๋•Œ๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค.

- [x] ์œ ๋ฃŒ ๊ฐ•์˜์˜ ๊ฒฝ์šฐ ๊ฒฐ์ œ๋Š” ์ด๋ฏธ ์™„๋ฃŒํ•œ ๊ฒƒ์œผ๋กœ ๊ฐ€์ •ํ•˜๊ณ  ์ดํ›„ ๊ณผ์ •์„ ๊ตฌํ˜„ํ•œ๋‹ค.
- [x] ๊ฒฐ์ œ๋ฅผ ์™„๋ฃŒํ•œ ๊ฒฐ์ œ ์ •๋ณด๋Š” payments ๋ชจ๋“ˆ์„ ํ†ตํ•ด ๊ด€๋ฆฌ๋˜๋ฉฐ, ๊ฒฐ์ œ ์ •๋ณด๋Š” Payment ๊ฐ์ฒด์— ๋‹ด๊ฒจ ๋ฐ˜ํ™˜๋œ๋‹ค.

### TODO
- [x] Course
- ๊ธฐ์ˆ˜
- List<Session>

- [x] Sessions
- List<Session>

- [x] Session
- SessionData(์‹œ์ž‘์ผ, ์ข…๋ฃŒ์ผ)
- ์ปค๋ฒ„ ์ด๋ฏธ์ง€ ์ •๋ณด
- ๊ฐ•์˜ ์œ ํ˜•(๋ฌด๋ฃŒ/์œ ๋ฃŒ)
- ๊ฐ•์˜ ์ƒํƒœ

- [x] ์ปค๋ฒ„ ์ด๋ฏธ์ง€ ์ •๋ณด
- gif, jpg, jpeg, png, svg๋งŒ ํ—ˆ์šฉ
- ์ด๋ฏธ์ง€ ํฌ๊ธฐ < 1
- width >= 300, height >= 200 / width * 2 = height * 3

- [x] ๋ฌด๋ฃŒ ๊ฐ•์˜
- ์ตœ๋Œ€ ์ˆ˜๊ฐ• ์ธ์› ์ œํ•œ ์—†์Œ

- [x] ์œ ๋ฃŒ ๊ฐ•์˜
- ๊ฐ•์˜ ์ตœ๋Œ€ ์ˆ˜๊ฐ•์ธ์›
- ๊ฐ•์˜ ์ตœ๋Œ€ ์ˆ˜๊ฐ•์ธ์› ์ดˆ๊ณผ ๋ถˆ๊ฐ€
- ์ˆ˜๊ฐ•๋ฃŒ
- ์ˆ˜๊ฐ•์ƒ์ด ๊ฒฐ์ œํ•œ ๊ธˆ์•ก == ์ˆ˜๊ฐ•๋ฃŒ ์ผ ๋•Œ๋งŒ ์ˆ˜๊ฐ•์‹ ์ฒญ ๊ฐ€๋Šฅ
- ๊ฒฐ์ œ ์™„๋ฃŒ List<Payment>

- [x] ๊ฐ•์˜ ์ƒํƒœ
- ์ค€๋น„์ค‘(Preparing)/๋ชจ์ง‘์ค‘(Recruiting)/์ข…๋ฃŒ(Closed)
- ๋ชจ์ง‘์ค‘์ผ ๋•Œ๋งŒ ์‹ ์ฒญ ๊ฐ€๋Šฅ

- [x] Payments
- List<Payment>
14 changes: 13 additions & 1 deletion src/main/java/nextstep/courses/domain/Course.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package nextstep.courses.domain;

import nextstep.courses.domain.session.Sessions;

import java.time.LocalDateTime;

public class Course {
Expand All @@ -13,19 +15,29 @@ public class Course {

private LocalDateTime updatedAt;

private Integer batchNumber;

private Sessions sessions;

public Course() {
}

public Course(String title, Long creatorId) {
this(0L, title, creatorId, LocalDateTime.now(), null);
this(0L, title, creatorId, LocalDateTime.now(), null, null, new Sessions());
}

public Course(Long id, String title, Long creatorId, LocalDateTime createdAt, LocalDateTime updatedAt) {
this(id, title, creatorId, createdAt, updatedAt, null, new Sessions());
}

public Course(Long id, String title, Long creatorId, LocalDateTime createdAt, LocalDateTime updatedAt, Integer batchNumber, Sessions sessions) {
this.id = id;
this.title = title;
this.creatorId = creatorId;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
this.batchNumber = batchNumber;
this.sessions = sessions;
}

public String getTitle() {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/nextstep/courses/domain/session/FreeSession.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nextstep.courses.domain.session;

import nextstep.payments.domain.Payment;

public class FreeSession implements SessionStrategy {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Session์ด๋ผ๋Š” ๋„๋ฉ”์ธ์ด ์ด๋ฏธ ์žˆ๊ณ  ํ˜„์žฌ ๊ตฌํ˜„์ฒด๋Š” Session์— ๋”ฐ๋ฅธ ๊ฒฐ์ œ ์ „๋žต์ด๊ธฐ ๋•Œ๋ฌธ์— ๋„ค์ด๋ฐ์ด FreeSessionEnrollStrategy์™€ ๊ฐ™์ด ์กฐ๊ธˆ ๋” ๋ช…ํ™•ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š” :)

@Override
public boolean canEnroll(Payment payment) {
return true;
}
}
35 changes: 35 additions & 0 deletions src/main/java/nextstep/courses/domain/session/PaidSession.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package nextstep.courses.domain.session;

import nextstep.payments.domain.Payments;
import nextstep.payments.domain.Payment;

public class PaidSession implements SessionStrategy {

private int maxEnrollmentCount;
private int currentEnrollmentCount;
private int tuitionFee;

private Payments payments;

public PaidSession(int maxEnrollmentCount, int currentEnrollmentCount, int tuitionFee){
this.maxEnrollmentCount = maxEnrollmentCount;
this.currentEnrollmentCount = currentEnrollmentCount;
this.tuitionFee = tuitionFee;
this.payments = new Payments();
}

private boolean isFull() {
return maxEnrollmentCount <= currentEnrollmentCount;
}

public void enroll(Payment payment){ //todo
if(canEnroll(payment)){
payments.add(payment);
}
}

@Override
public boolean canEnroll(Payment payment) {
return !isFull() && payment.isTuitionPaid(tuitionFee);
}
Comment on lines +25 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ตฌ์กฐ๊ฐ€ ์–ด์ƒ‰ํ•ด๋ณด์ด๋Š” ์ด์œ ๋Š” PaidSessionEnrollStrategy๋ฅผ ์–ด๋–ป๊ฒŒ ํ™œ์šฉํ• ๊ฑด์ง€ ๋ช…ํ™•ํ•˜์ง€ ์•Š์•„์„œ์ธ ๊ฒƒ ๊ฐ™์•„์š”. ์ง€๊ธˆ ์„ค๊ณ„ํ•œ ๊ฐ์ฒด์˜ ์—ญํ• ๋กœ๋ณด๋ฉด,

  • ๊ฐ•์˜๊ฐ€ ๊ฒฐ์ œ๊ฐ€๋Šฅํ•œ ์ƒํ™ฉ์ธ์ง€ ํ™•์ธํ•ด์ค€๋‹ค.
    • ์ด๋ฅผ ์œ„ํ•ด ํ˜„์žฌ ์ˆ˜๊ฐ•์ƒ ์ˆ˜, ์ตœ๋Œ€ ์ˆ˜๊ฐ•์ƒ ์ˆ˜, ๊ฐ•์˜๋ฃŒ๋ฅผ ๊ฐ€์ง„๋‹ค.
  • ๊ฒฐ์ œ๋ฅผ ๋ฐ›์•„ ์ˆ˜๊ฐ•๋“ฑ๋กํ•œ๋‹ค.

๋ผ๊ณ  ๋ฐ”๋ผ๋ณธ๋‹ค๋ฉด SessionEnrollStrategy๋Š” "์ˆ˜๊ฐ• ๋“ฑ๋ก"์ด๋ผ๋Š” ๋ช…์ œ๋งŒ ๋™์ž‘ํ•ด์ฃผ๋ฉด๋˜๊ณ , canEnroll์ด ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ์˜ˆ์™ธ๋ฅผ ํ„ฐํŠธ๋ฆฌ๋Š” ๋“ฑ๊ณผ ๊ฐ™์€ ํ–‰์œ„๋กœ ์ƒ๊ฐํ•ด๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”.

public interface SessionEnrollStrategy {    
    void enroll(Payment payment);
}

๊ฐ€ ๋˜์–ด์•ผํ•˜๊ณ ,

public class PaidSessionEnrollStrategy {
   // ..
   public void enroll(Payment payment) {
        // canEnroll์ด ์•„๋‹Œ ๊ฒฝ์šฐ ์˜ˆ์™ธ
        // count๋ฅผ ์˜ฌ๋ฆฌ๊ณ  ๊ฒฐ์ œ์ •๋ณด ์ €์žฅ

์ด ๋  ์ˆ˜ ์žˆ๊ฒ ์ฃ . ๋‹ค๋งŒ ํ•ด๋‹น ํด๋ž˜์Šค๋„ ์ „๋žต์œผ๋กœ ๋ถˆ๋ฆฌ๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ˜ผ๋™์„ ์ค„ ์ˆ˜ ์žˆ๋Š”๋ฐ์š”. "์ „๋žต"์ด๋ผ๋Š” ๊ฒƒ์€ ์–ด๋–ค ํ–‰์œ„๋ฅผ ์–ด๋–ป๊ฒŒ ์‹คํ–‰ํ•˜๋Š๋ƒ๊ฐ€ ์ฃผ์š” ๊ด€์‹ฌ์‚ฌ์ด์ง€ ์ƒํƒœ๋ฅผ ๋“ค๊ณ  ๊ด€๋ฆฌํ•˜๋ฉด์„œ ์ „๋žต์„ ์ถ”๊ตฌํ•˜๋Š”๊ฑด ์ „๋žต์ž์ฒด์˜ ์ฑ…์ž„์„ ํ™•์žฅ์‹œ์ผœ๋ฒ„๋ฆด ์ˆ˜ ์žˆ์–ด์š”. ์ถ”์ƒํ™”๋ฅผ ํ†ตํ•œ ์ ‘๊ทผ์€ ๋งž์ง€๋งŒ ์ „๋žต์ด๋ƒ๋Š” ๊ณ ๋ฏผํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋„ค์š” :)

}
37 changes: 37 additions & 0 deletions src/main/java/nextstep/courses/domain/session/Session.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package nextstep.courses.domain.session;

import nextstep.courses.domain.session.coverImage.SessionCoverImage;
import nextstep.payments.domain.Payment;

import java.time.LocalDate;

public class Session {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SessionService๋ฅผ ํ†ตํ•ด enroll ๋กœ์ง์„ ๊ตฌํ˜„ํ•˜๋Š”๊ฒƒ๊นŒ์ง€๊ฐ€ ๋ฏธ์…˜์˜ ์š”๊ตฌ์‚ฌํ•ญ์ด์—์š” :)


private SessionDate sessionDate;
private SessionCoverImage sessionCoverImage;
private SessionStatus sessionStatus;
private SessionStrategy sessionStrategy;

public Session(SessionCoverImage sessionCoverImage, SessionStatus sessionStatus, SessionStrategy sessionStrategy) {
this(null, null, sessionCoverImage, sessionStatus, sessionStrategy);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‘˜๋‹ค null์ธ ์ผ€์ด์Šค๋ฅผ ์ƒ์„ฑ์ž์—์„œ ์ง€์›ํ•˜๋Š” ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?

}

public Session(LocalDate startDate, LocalDate endDate, SessionCoverImage sessionCoverImage, SessionStatus sessionStatus, SessionStrategy sessionStrategy) {
this.sessionDate = new SessionDate(startDate, endDate);
this.sessionCoverImage = sessionCoverImage;
this.sessionStatus = sessionStatus;
this.sessionStrategy = sessionStrategy;
}

public boolean isValidCoverImage() {
return sessionCoverImage.isValidCoverImage();
}

public boolean canEnroll(Payment payment) {
return sessionStrategy.canEnroll(payment) && isRecruiting();
}

private boolean isRecruiting() {
return sessionStatus.isRecruiting();
}
}
13 changes: 13 additions & 0 deletions src/main/java/nextstep/courses/domain/session/SessionDate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package nextstep.courses.domain.session;

import java.time.LocalDate;

public class SessionDate {
private LocalDate startDate;
private LocalDate endDate;

public SessionDate(LocalDate startDate, LocalDate endDate){
this.startDate = startDate;
this.endDate = endDate;
}
}
12 changes: 12 additions & 0 deletions src/main/java/nextstep/courses/domain/session/SessionStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package nextstep.courses.domain.session;

public enum SessionStatus {

PREPARING,
RECRUITING,
CLOSED;

public boolean isRecruiting(){
return this == RECRUITING;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package nextstep.courses.domain.session;

import nextstep.payments.domain.Payment;

@FunctionalInterface
public interface SessionStrategy {
boolean canEnroll(Payment payment);
}
7 changes: 7 additions & 0 deletions src/main/java/nextstep/courses/domain/session/Sessions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package nextstep.courses.domain.session;

import java.util.List;

public class Sessions {
private List<Session> values;
}
Comment on lines +5 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฐœ์ธ์ ์œผ๋กœ ๋‹จ์ˆœํžˆ ๋ž˜ํ•‘๋งŒํ•˜๋Š” ํด๋ž˜์Šค๋Š” ์ผ๊ธ‰์ปฌ๋ž™์…˜์œผ๋กœ ๋ฌถ์„ ํ•„์š”๋Š” ์—†๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ํŠน์ • ๋„๋ฉ”์ธ ์ฑ…์ž„ ์—†์ด ๋ฆฌ์ŠคํŠธ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ผ๊ธ‰์ปฌ๋ž™์…˜์œผ๋กœ ๋‘”๋‹ค๋Š” ๊ฒƒ์€ ๊ณผํ•œ ๋ž˜ํ•‘์ด ๋  ์ˆ˜ ์žˆ์–ด์š”.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package nextstep.courses.domain.session.coverImage;

public class ImageDimensions {
private int width;
private int height;

private static final int MIN_WIDTH = 300;
private static final int MIN_HEIGHT = 200;
private static final int WIDTH_RATIO = 3;
private static final int HEIGHT_RATIO = 2;

public ImageDimensions(int width, int height) {
this.width = width;
this.height = height;
}

public boolean validDimensions() {
Comment on lines +12 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ƒ์„ฑ์ž์—์„œ validation์„ ํ•˜์ง€ ์•Š์œผ์‹œ๋Š” ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”? ๊ฐ์ฒด์˜ ์ƒ์„ฑ์€ ๊ฐ์ฒด๊ฐ€ ๋‹ด๋‹นํ•˜๋Š” ๊ฒƒ์ด ๊ฐ์ฒด ์ƒ์„ฑ์˜ ์•ˆ์ •์„ฑ์„ ๋ณด์žฅํ•ด์š” :)

if (width < MIN_WIDTH || height < MIN_HEIGHT) {
throw new IllegalArgumentException("์ด๋ฏธ์ง€์˜ ๋„ˆ๋น„๋Š” 300ํ”ฝ์…€, ๋†’์ด๋Š” 200ํ”ฝ์…€ ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
}
if (width * HEIGHT_RATIO != height * WIDTH_RATIO) {
throw new IllegalArgumentException("๋„ˆ๋น„์™€ ๋†’์ด์˜ ๋น„์œจ์€ 3:2์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package nextstep.courses.domain.session.coverImage;

import java.util.Arrays;
import java.util.List;

public enum ImageExtension {
GIF,
JPG,
JPEG,
PNG,
SVG,
BMP;

private static final List<ImageExtension> VALID_EXTENSION = Arrays.asList(GIF, JPG, JPEG, PNG, SVG);

public static boolean validExtension(ImageExtension extension) {
if (!VALID_EXTENSION.contains(extension)) {
throw new IllegalArgumentException("ํ—ˆ์šฉ๋˜์ง€ ์•Š์€ ํ™•์žฅ์ž ์ž…๋‹ˆ๋‹ค.");
}
return true;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package nextstep.courses.domain.session.coverImage;

public class ImageSize {
private int size;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ถˆ๋ณ€์ผ ์ˆ˜ ์žˆ๋Š” ํ•„๋“œ๋“ค์€ ๋ชจ๋‘ ๋ถˆ๋ณ€์œผ๋กœ ์ˆ˜์ •ํ•ด์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š” :)


private static final int MAX_SIZE = 1;

public ImageSize(int size) {
this.size = size;
}

public boolean validSize() {
if (size > MAX_SIZE) {
throw new IllegalArgumentException("์ด๋ฏธ์ง€๋Š” 1MB ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package nextstep.courses.domain.session.coverImage;

public class SessionCoverImage {
private ImageSize imageSize;
private ImageExtension imageExtension;
private ImageDimensions imageDimensions;

public SessionCoverImage(int size, ImageExtension imageExtension, int width, int height) {
this(new ImageSize(size), imageExtension, new ImageDimensions(width, height));
}

public SessionCoverImage(ImageSize imageSize, ImageExtension imageExtension, ImageDimensions imageDimensions) {
this.imageSize = imageSize;
this.imageExtension = imageExtension;
this.imageDimensions = imageDimensions;
}

public boolean isValidCoverImage() {
return imageSize.validSize()
&& ImageExtension.validExtension(imageExtension)
&& imageDimensions.validDimensions();
}
}
8 changes: 8 additions & 0 deletions src/main/java/nextstep/payments/domain/Payment.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ public class Payment {
public Payment() {
}

public Payment(Long amount) {
this(null, null, null, amount);
}

public Payment(String id, Long sessionId, Long nsUserId, Long amount) {
this.id = id;
this.sessionId = sessionId;
this.nsUserId = nsUserId;
this.amount = amount;
this.createdAt = LocalDateTime.now();
}

public boolean isTuitionPaid(int tuitionFee) {
return tuitionFee == amount;
}
}
12 changes: 12 additions & 0 deletions src/main/java/nextstep/payments/domain/Payments.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package nextstep.payments.domain;

import java.util.ArrayList;
import java.util.List;

public class Payments {
private List<Payment> values = new ArrayList<>();

public void add(Payment payment){
values.add(payment);
}
}
Loading