-
Notifications
You must be signed in to change notification settings - Fork 308
๐ 4๋จ๊ณ - ์๊ฐ์ ์ฒญ(์๊ตฌ์ฌํญ ๋ณ๊ฒฝ) #808
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
base: chanani
Are you sure you want to change the base?
Conversation
โฆ ํตํด์ Entity, Domain ํด๋์ค ๋ฐํ)
โฆ ํ ํ์ํ ํด๋์ค์ ์์(SessionCore ์๊ตฌ์ฌํญ ์ถ๊ฐ๋ก ์ธํด ์์์ด ์๋ ์ธ์คํด์ค ๋ณ์๋ก ์ฌ์ฉํ๋ ๊ฒ์ด ์ข๊ฒ ๋ค๊ณ ํ๋จ.)
SessionCoreV2์์ ์ถ๊ฐ๋ ์๊ตฌ์ฌํญ ์ ์ฉ ์์
- session ํ ์ด๋ธ ์์ cover_image_id๋ฅผ ๊ด๋ฆฌํ๋๋ฐ cover_image ํ ์ด๋ธ์์ session_id ๊ด๋ฆฌํ ์ ์๋๋ก ์์ - DB ํ ์ด๋ธ์ ๋ฐ์ดํฐ๊ฐ ์กด์ฌํ๋ค๋ ๊ฐ์ ํ์ ๋ฆฌํฉํฐ๋ง ์งํํ๋ผ๋ ์๊ตฌ์ฌํญ์ด ์์๋๋ฐ, ์ต์ด DB ์ค๊ณ ์ ๋ฌธ์ ๋ก ์ด๋ฅผ ์งํค์ง ๋ชปํ์ต๋๋ค. ํ์ง๋ง ์ค๋ฌด์์ ์ด๋ฐ ์ํฉ์ด ์จ๋ค๋ฉด, ๊ธฐ์กด ๋ฐ์ดํฐ์ ๋ฌธ์ ๋์ง ์๋๋ก ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํ ๊ฒ๊ฐ์ต๋๋ค.
refactor : ์๊ฐ์ ์ฒญ ๊ฐ์ฒด์ ์ํ๊ฐ ์ถ๊ฐ ๋ฐ ํ ์คํธ ์ฝ๋ ์์ฑ
javajigi
left a comment
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.
๋๋์ด ๋ฏธ์
์ ๋ง์ง๋ง ๋จ๊ณ๋จ์. ๐
์๊ตฌ์ฌํญ์ ์ ํํ ์ ํ์
ํด ๊ตฌํ ์ ํ๋ค์.
๋จ, Session์ ๋ณต์ก๋๋ฅผ ๋ฎ์ถ๊ณ ์ธํฐํ์ด์ค ์ฌ์ฉ๊ณผ ๊ด๋ จํ ํผ๋๋ฐฑ ๋จ๊ฒผ์ผ๋ ํ๋ฒ ๊ณ ๋ฏผํด ๋ณด๋ ์๊ฐ์ ๊ฐ์ง๋ฉด ์ข๊ฒ ์ต๋๋ค.
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class CoverImages { |
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.
์ผ๊ธ ์ฝ๋ ์ ์ ์ฉ ๐
|
|
||
| import java.util.Arrays; | ||
|
|
||
| public enum EnrollmentStatus { |
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.
๐
|
|
||
| import java.util.Arrays; | ||
|
|
||
| public enum SelectionStatus { |
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.
๐
| @@ -0,0 +1,15 @@ | |||
| package nextstep.courses.domain.session.constant; | |||
|
|
|||
| public enum SessionRecruitmentStatus { | |||
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.
์ํ ๊ฐ์ ๋ถ๋ฆฌ ๐
| } | ||
|
|
||
| private boolean isSelectedAndCancelled(EnrollmentStatus enrollmentStatus) { | ||
| return this.selectionStatus.equals(SelectionStatus.SELECTED) && enrollmentStatus.equals(EnrollmentStatus.CANCELLED); |
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.
| return this.selectionStatus.equals(SelectionStatus.SELECTED) && enrollmentStatus.equals(EnrollmentStatus.CANCELLED); | |
| return this.selectionStatus.isSelected() && enrollmentStatus.isCancled(); |
enum๋ class์ ๊ฐ์ด ๋ฉ์์ง๋ฅผ ๋ณด๋ด๋ ๋ฐฉ์์ผ๋ก ๊ตฌํ ๊ฐ๋ฅํจ
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public interface SessionCoreFacade { |
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.
์ธํฐํ์ด์ค์ ๋ฉ์๋๊ฐ ๋๋ฌด ๋ง๋ค.
์ธํฐํ์ด์ค์ ๋ฉ์๋๊ฐ ๋๋ฌด ๋ง์ ๊ฒฝ์ฐ ์ธํฐํ์ด์ค ์ค๊ณ๊ฐ ์๋ชป๋์์ ๊ฐ๋ฅ์ฑ์ด ๋์
์ด๋ด ๊ฒฝ์ฐ ์ธํฐํ์ด์ค๋ฅผ ์ฑ
์์ ๋ฐ๋ผ ๋ถ๋ฆฌํ๊ฑฐ๋, ๋ถํ์ํ ๋ฉ์๋๋ฅผ ์ ๊ฑฐํ ํ์๊ฐ ์์
๋ํ ์ด ์ธํฐํ์ด์ค๊ฐ ํ์ํ์ง์ ๋ํด์๋ ๊ณ ๋ฏผํด ๋ณด๋ฉด ์ข๊ฒ ๋ค.
| SessionRecord sessionRecord = sessionRepository.findById(enrollment.getSessionId()); | ||
| List<EnrollmentRecord> enrollmentRecords = enrollmentRepository.findBySessionId(enrollment.getSessionId()); | ||
| Session session = sessionRecord.toSession(null, null, toEnrollments(enrollmentRecords)); | ||
| Session session = SessionMapper.toDomain(sessionRecord, null, null, toEnrollments(enrollmentRecords)); | ||
| session.addEnrollment(enrollment, payment); | ||
|
|
||
| paymentRepository.save(payment); | ||
|
|
||
| return enrollmentRepository.save(enrollment); |
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.
์ด ๋ฏธ์
์ ๊ฐ์ฒด ์ค๊ณ์์ ์๊ฐ ์ ์ฒญ ๊ฐ๋ฅ ์ฌ๋ถ๋ฅผ ํ์ธํ๋ ๊ฒ์ด ๋ณต์ก๋๊ฐ ๊ฐ์ฅ ๋์ ๋ถ๋ถ์ด์ด๋ค.
์ด ๋ถ๋ถ์ Session ๊ฐ์ฒด ๋ด์ ๋๋ ๊ฒ์ด ์๋๋ผ ์๋์ ๊ฐ์ด Session์ ํตํด ์๊ฐ์ ์ฒญ์ ํ์ํ ๊ฐ์ฒด๋ฅผ ์๋์ Enrollment์ ๊ฐ์ ๊ฐ์ฒด๋ก ์์ฑํ ํ ์์ํจ์ผ๋ก์จ ๋ณต์ก๋๋ฅผ ๋ฎ์ถ๋ ๋ฐฉ์์ผ๋ก ์ ๊ทผํด ๋ณด๋ ๊ฒ์ ์ด๋จ๊น?
์๋ ์ฝ๋์์ Enrollment๋ ์๊ฐ ์ ์ฒญ ๊ฐ๋ฅ ์ฌ๋ถ๋ฅผ ํ๋จํ๋ ๋ก์ง์ ๋ด๋นํ๋ ๊ฐ์ฒด๋ก ์ฐฌํ๋ ์ฝ๋์ Enrollment์๋ ๋ค๋ฆ
์ฐฌํ๋์ Enrollment๋ ์๋ ์ฝ๋์์ Student์
SessionRecord sessionRecord = ...
List<EnrollmentRecord> enrollmentRecords = ...
Enrollment enrollment = sessionRecord.createEnrollment(enrollmentRecords);
Student student = enrollment.enroll(user);
enrollmentRepository.save(student.getUserId(), student.getSessionId());์ ์ฝ๋์์ ๋ฆฌํฉํฐ๋ง ํํธ๋ฅผ ์ป์ ์ ์๋ ๋ถ๋ถ์ด ์๋ค๋ฉด ๋ฆฌํฉํฐ๋งํด ๋ณธ๋ค.
์๋ ํ์ธ์ ! ์๊ฐ์ ์ฒญ 4๋จ๊ณ ๋ฆฌ๋ทฐ ์์ฒญ๋๋ฆฝ๋๋ค.๐โโ๏ธ
์ต์ด ํ ์ด๋ธ ์ค๊ณ ์ session ํ ์ด๋ธ์์ cover_image_id๋ฅผ ๊ฐ์ง๊ณ ์์์ต๋๋ค.
1:1 ๊ด๊ณ์์ 1:N ์ํ๋ก ๋ณ๊ฒฝ๋๋ฉด์ ๊ธฐ์กด๊ณผ ๋ค๋ฅด๊ฒ cover_image ํ ์ด๋ธ์์ session_id๋ฅผ ๊ฐ์ง๊ณ ์์ด์ผ ๋๋ค๊ณ ํ๋จ๋์ด ๋ถ๊ฐํผํ๊ฒ ํ ์ด๋ธ์ ์์ ํ์ต๋๋ค.
DB ํ ์ด๋ธ์ ๋ฐ์ดํฐ๊ฐ ์กด์ฌํ๋ค๋ ๊ฐ์ ํ์ ๋ฆฌํฉํฐ๋ง์ ์งํํ๋ผ๋ ์๊ตฌ์ฌํญ์ด ์์๋๋ฐ, ์ด๋ฅผ ์งํค์ง ๋ชปํ์ต๋๋ค.
์ ๊ฐ ๋ง์ง๋ง ์๊ตฌ์ฌํญ์ ์ ์ดํดํ๊ณ ์งํํ๊ฑด์ง ํ์ ์ด ๋ค์ง ์์ต๋๋ค.
์ฐ์ํํ ํฌ์ฝ์ค(๋ฌด๋ฃ), ์ฐ์ํํ ํฌ์บ ํ Pro(์ ๋ฃ)์ ๊ฐ์ด ์ ๋ฐ๋ ์ธ์๋ง ์๊ฐ ๊ฐ๋ฅํด์ผ ํ๋ค.๋ผ๋ ์กฐ๊ฑด์์ ์ ๋ฐ ์ฌ๋ถ๋ ์์ ์ด ๊ฐ๋ฅํ ์ชฝ์ผ๋ก ์์ ์ ์งํํ๋๋ฐ, ํน์๋ผ๋ ์๊ตฌ์ฌํญ์ ์ ๋๋ก ํ์ ํ์ง ๋ชปํ ๋ถ๋ถ์ด ์์ ๊ฒฝ์ฐ ์์ ํ๊ฒ ์ต๋๋ค.