-
Notifications
You must be signed in to change notification settings - Fork 299
๐ 1๋จ๊ณ - ๋ ๊ฑฐ์ ์ฝ๋ ๋ฆฌํฉํฐ๋ง #790
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
โฆ ๊ถํ ์ฒดํฌ ๋ฉ์๋ ์์ฑ ๋ฐ ํ ์คํธ ์ฝ๋ ์์ฑ
โฆwerOwner ๋ฉ์๋ ํธ์ถ
โฆ์ด๋ป๊ฒ ์ฒ๋ฆฌํ๋ฉด ์ข์์ง ๊ณ ๋ฏผ์ค) ๋ฐ ํ ์คํธ ์ฝ๋ ์์ฑ
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.
๋๋์ด ํ์ฅ๊ณผ ๋น์ทํ ์ฝ๋์ธ ๋ ๊ฑฐ์ ์ฝ๋ ๋ฆฌํฉํฐ๋ง ๋ฏธ์
์งํํ๊ตฐ์. ๐
๋ช ๊ฐ์ง ๊ณ ๋ฏผํด๋ณด๋ฉด ์ข๊ฒ ๋ค ์๊ฐํ๋ ๋ถ๋ถ์ ๋ํด ํผ๋๋ฐฑ ๋จ๊ฒผ์ผ๋ ํ๋ฒ ๊ณ ๋ฏผํด ๋ณด๋ฉด ์ข๊ฒ ์ต๋๋ค.
| ## ์ฝ๋ ๋ฆฌ๋ทฐ | ||
| > PR ๋งํฌ : | ||
| ## ๋์ ํ์ต ๋ชฉํ |
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,12 @@ | |||
| # โ๏ธ PR ์ ํ์ธํด์ผ๋ ๋ชฉ๋ก | |||
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.
๐
| throw new CannotDeleteException("๋ค๋ฅธ ์ฌ๋์ด ์ด ๋ต๋ณ์ด ์์ด ์ญ์ ํ ์ ์์ต๋๋ค."); | ||
| } | ||
| } | ||
|
|
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.
ํ์ฌ๋ valid์ updateDeleted๊ฐ ๋ถ๋ฆฌ๋์ด ๊ตฌํ๋์ด ์์.
์ด ๋์ ํ๋๋ก ๊ตฌํํ๋ ์๋์ ๋น๊ตํ์ ๋ ์ด๋ ๋ฐฉ์์ผ๋ก ๊ตฌํํ๋ ๊ฒ์ด ๋ ์ข์๊น?
| public void delete(NsUser loginUser) throws CannotDeleteException { | |
| // ์ ํจ์ฑ ์ฒดํฌ์ ์ญ์ ์ํ๋ก ๋ณ๊ฒฝ | |
| } |
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.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class Answers { |
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.
์ผ๊ธ ์ฝ๋ ์ ์ ์ฉ ๐
| } | ||
| } | ||
|
|
||
| public List<DeleteHistory> delete(long questionId) { |
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.
| public List<DeleteHistory> delete(long questionId) { | |
| public List<DeleteHistory> delete() { |
questionid๋ Question์ด ๊ฐ์ง๊ณ ์์.
๊ตณ์ด ํ์์์ง ์์๊น?
| } | ||
| } | ||
|
|
||
| public List<DeleteHistory> delete(long questionId) { |
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.
| public List<DeleteHistory> delete(long questionId) { | |
| public void delete(NsUser loginUser) { |
Answer ํผ๋๋ฐฑ๊ณผ ๊ฐ์ด ํ์ฌ ๋๋ก ๋ถ๋ฆฌ๋์ด ์๋ ๊ตฌํ๊ณผ ์์ ๊ฐ์ด ์ญ์ ๊ถํ ์ฒดํฌ์ฌ๋ถ์ deleted ์ํ ๋ณ๊ฒฝ ๋ก์ง์ ํจ๊ป ๊ตฌํํ๋ ์ ์ ๊ทผ ๋ฐฉ์ ์ค ์ด๋ ์ ๊ทผ ๋ฐฉ์์ด ์ข์์ง ๊ณ ๋ฏผํด ๋ณด๋ฉด ์ด๋จ๊น?
|
|
||
| return deleteHistories; | ||
| } | ||
|
|
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.
ํ์ฌ๋ delete()์์ ์ํ ๋ณ๊ฒฝ๊ณผ List ์์ฑ ํ ๋ฐํํ๋ ํ์ฌ ๊ตฌํ๊ณผ delete()์ toDeleteHistories()์ ๊ฐ์ด ์ํ ๋ณ๊ฒฝ๊ณผ List ๋ฐํํ๋ ๋ฉ์๋ ๋ ๊ฐ๋ก ๋ถ๋ฆฌํ๋ ๊ฒ ์ค ์ด๋ ์ ๊ทผ ๋ฐฉ์์ด ์ข์๊น?
| } | ||
|
|
||
|
|
||
|
|
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.
Answers ์ผ๊ธ ์ฝ๋ ์ ์ ๋ํ ๋จ์ ํ ์คํธ๋ ์ถ๊ฐํ๋ฉด ์ด๋จ๊น?
์ํ๋ฅผ ๋ณ๊ฒฝํ๋ ๋ฉ์๋์ ์ญ์ ๋ด์ญ์ ๋จ๊ธฐ๋ history๋ฅผ ๋ถ๋ฆฌ
refactor : answer ํ ์คํธ ์ฝ๋ ์ถ๊ฐ, Question ํ ์คํธ ์ฝ๋ ๋ด๋ถ ์์
|
๋ฆฌ๋ทฐํด ์ฃผ์ ๊ฒ๊ณผ ๊ฐ์ด ์์ ํด๋ดค์ต๋๋ค ! ํ ๋ฉ์๋๋ ํ๋์ ์ญํ ๋ง ํด์ผ๋๋ค๋ ์๊ฐ์ผ๋ก ๊ฒ์ฆํ๋ ๋ก์ง๊ณผ ์ํ๋ฅผ ๋ณ๊ฒฝํ๋ ๋ก์ง์ด Service(deleteQuestion)์์ ๊ฐ๊ฐ ํธ์ถ ๋์ด์ผ ํ๋ค๊ณ ์๊ฐํ์ต๋๋ค.
์ถ๊ฐ๋ก ํผ๋๋ฐฑ ์ ์์ ํด ๋์ ๋ด์ฉ ์๋๋ฐ ํ์ธ ๋ชปํ์
จ์ ๊ฒ ๊ฐ์ ๋ง์๋๋ฆฝ๋๋ค ! |
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.
BaseModel ๋ถ๋ฆฌ ์ธ์์ ์ด๋ค์. ๐
๋จ, ์ด ๊ฐ์ ์ถ์ ํด๋์ค๋ฅผ ๋ถ๋ฆฌํ์ ๋ ๊ณ ๋ คํด์ผํ ๋ถ๋ถ ํผ๋๋ฐฑ ๋จ๊ฒผ์ผ๋ ํ์ธํด ๋ณด์ธ์.
| return this; | ||
| } | ||
|
|
||
| public void updateDeleted() { |
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์ผ๋ก ๊ตฌํํด์ผ ์์ ํ์ง ์์๊น?
| throw new CannotDeleteException("๋ค๋ฅธ ์ฌ๋์ด ์ด ๋ต๋ณ์ด ์์ด ์ญ์ ํ ์ ์์ต๋๋ค."); | ||
| } | ||
| } | ||
|
|
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.
์ด ํผ๋๋ฐฑ ๋ฐ์ํ๋์ง ํ์ธ ํ์
| } | ||
| } | ||
|
|
||
| public void addDeleteAnswerHistory(List<DeleteHistory> deleteHistories) { |
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.
| public void addDeleteAnswerHistory(List<DeleteHistory> deleteHistories) { | |
| public List<DeleteHistory> toDeleteAnswerHistories() { | |
| List<DeleteHistory> deleteHistories = new ArrayList<>(); |
๊ฐ์ธ์ ์ผ๋ก List ์ฝ๋ ์ ์ ์ธ์๋ก ์ ๋ฌํด ์ ์ฅํ๋ ๊ฒ๋ณด๋ค ์์ ๊ฐ์ด ํด๋น ๋ฉ์๋์์ ์ง์ ์์ฑํด ๋ฐํํ๋ ๊ฒ์ด ๋ค๋ฅธ ๊ฐ์ฒด์์ ์์กด ๊ด๊ณ๊ฐ ๋ฐ์ํ์ง ์๊ธฐ ๋๋ฌธ์ ์ ํธํ๋ ๋ฐฉ๋ฒ์
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public abstract class BaseModel { |
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.
๐
๋จ, ํ๋ก์ ํธ์ ๋ชจ๋ ์ปจํ
์ธ ๋ ์ฑ๊ฒฉ์ ๋ฐ์ดํฐ๋ soft delete ์ ์ฑ
์ ๋ฐ๋ฅธ๋ค์ ๊ฐ์ ๊ท์น์ด ์์ ๊ฒฝ์ฐ deleted ์ํ๋ฅผ ํฌํจํ๋ ๊ฒ์ด ์ถ์ํ ์ธก๋ฉด์์ ๋ง์.
์ด๋ ๊ฒ ๋ ๊ฒฝ์ฐ ์ด BaseModel์ ์ด ๊ท์น์ ๋ฐ๋ฅด์ง ์๋ Model์ ์์ํ ์ ์๊ธฐ ๋๋ฌธ์ ๊ฐ์ฒด์ ์ด๋ฆ์ ๋ ๊ตฌ์ฒด์ ์ผ๋ก ์์ฑํ ๊ฒ์ ์ถ์ฒ
AI์๊ฒ ํ๋ก์ ํธ์ ์ ์ฑ
์ ์ค๋ช
ํ๊ณ ๋ ์ ํฉํ ์ด๋ฆ์ ์ถ์ฒ ๋ฐ์๋ณธ๋ค.
| public LocalDateTime createdDate = LocalDateTime.now(); | ||
|
|
||
| public LocalDateTime updatedDate; | ||
|
|
||
| public boolean deleted = false; |
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.
| public LocalDateTime createdDate = LocalDateTime.now(); | |
| public LocalDateTime updatedDate; | |
| public boolean deleted = false; | |
| private LocalDateTime createdDate = LocalDateTime.now(); | |
| private LocalDateTime updatedDate; | |
| private boolean deleted = false; |
๋ชจ๋ ์ธ์คํด์ค ๋ณ์๋ ๊ฐ๋ฅํ๋ฉด private์ผ๋ก ๊ตฌํ
| public LocalDateTime createdDate = LocalDateTime.now(); | ||
|
|
||
| public LocalDateTime updatedDate; | ||
|
|
||
| public boolean deleted = false; |
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.
| public LocalDateTime createdDate = LocalDateTime.now(); | |
| public LocalDateTime updatedDate; | |
| public boolean deleted = false; | |
| private boolean deleted = false; |
๊ทธ๋ผ ์ํ ๊ฐ ๋ณ๊ฒฝ์ ์ด๋ป๊ฒ ํ๋?
protected void deleted() {
this.deleted = true;
}์๋์ ๊ฐ์ด protected ๋ฉ์๋๋ฅผ ์ ๊ณตํ๊ณ ์์ ํด๋์ค์์ ํธ์ถํ ์ ์๋๋ก ํ๋ค.
| @@ -0,0 +1,10 @@ | |||
| package nextstep.qna.domain; | |||
|
|
|||
| public class Contents { | |||
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.
์ด ๊ฐ์ฒด๋ ๊ฐ์ ํฌ์ฅํ๋ ๊ฒ ์ธ์ ์๋ฌด ๋ก์ง๋ ์๋๋ฐ ํฌ์ฅํ๋ ๊ฒ์ด ์๋ฏธ์์๊น?
Title ๋์ผ
๋จ, title๊ณผ contents๋ฅผ ์ธ์คํด์ค ๋ณ์๋ฅผ ๊ฐ์ง๋ QuestionBody์ ๊ฐ์ ๊ฐ์ฒด๋ฅผ ๋ถ๋ฆฌํ๋ค๋ฉด ์๋ฏธ์์๊น?
์๋ ํ์ธ์ ! ๋ ๊ฑฐ์ ์ฝ๋ ๋ฆฌํฉํฐ๋ง 1๋จ๊ณ ๋ฆฌ๋ทฐ ์์ฒญ๋๋ฆฝ๋๋ค ! ๐โโ๏ธ
๋จผ์ ํธ์ฑ๋์ ๋ชฉํ ์ค์ ๊ณผ ์ฒดํฌ๋ฆฌ์คํธ๋ฅผ ๋ณด๊ณ ์ ๋ง์ ํ์ต ๋ชฉํ๋ฅผ ์์ฑํ์ฌ ์ด๋ฒ ๊ณผ์ ์์ ๋์ณ์๋ ์๋ ๋ถ๋ถ๋ค์ ์์ํ๋ฉฐ, ๊ณผ์ ๋ฅผ ์งํํ์ต๋๋ค.
์์ง์ ๊ธฐ์กด ์ฝ๋๋ฅผ ๋ฆฌํฉํฐ๋งํ๋ ๊ฒ์ด ์ํฌ๋ฅด๊ณ , ์ด์ํ๊ฒ ๋๊ปด์ง์ง๋ง ์ด ๊ณผ์ ์ ํตํด ๋ง์ ๊ฒ์ ๋ฐฐ์ ์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค.