Skip to content

Conversation

@chanani
Copy link

@chanani chanani commented Nov 26, 2025

์•ˆ๋…•ํ•˜์„ธ์š” ! ๋ ˆ๊ฑฐ์‹œ ์ฝ”๋“œ ๋ฆฌํŒฉํ„ฐ๋ง 1๋‹จ๊ณ„ ๋ฆฌ๋ทฐ ์š”์ฒญ๋“œ๋ฆฝ๋‹ˆ๋‹ค ! ๐Ÿ™‡โ€โ™‚๏ธ

๋จผ์ € ํ˜ธ์„ฑ๋‹˜์˜ ๋ชฉํ‘œ ์„ค์ •๊ณผ ์ฒดํฌ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณด๊ณ  ์ €๋งŒ์˜ ํ•™์Šต ๋ชฉํ‘œ๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์ด๋ฒˆ ๊ณผ์ •์—์„œ ๋†“์ณ์„œ๋Š” ์•ˆ๋  ๋ถ€๋ถ„๋“ค์„ ์˜์‹ํ•˜๋ฉฐ, ๊ณผ์ œ๋ฅผ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.

์•„์ง์€ ๊ธฐ์กด ์ฝ”๋“œ๋ฅผ ๋ฆฌํŒฉํ„ฐ๋งํ•˜๋Š” ๊ฒƒ์ด ์„œํˆฌ๋ฅด๊ณ , ์–ด์ƒ‰ํ•˜๊ฒŒ ๋А๊ปด์ง€์ง€๋งŒ ์ด ๊ณผ์ •์„ ํ†ตํ•ด ๋งŽ์€ ๊ฒƒ์„ ๋ฐฐ์› ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

โ€ฆ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋ฉด ์ข‹์„์ง€ ๊ณ ๋ฏผ์ค‘) ๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

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

๋“œ๋””์–ด ํ˜„์žฅ๊ณผ ๋น„์Šทํ•œ ์ฝ”๋“œ์ธ ๋ ˆ๊ฑฐ์‹œ ์ฝ”๋“œ ๋ฆฌํŒฉํ„ฐ๋ง ๋ฏธ์…˜ ์ง„ํ–‰ํ–ˆ๊ตฐ์š”. ๐Ÿ‘
๋ช‡ ๊ฐ€์ง€ ๊ณ ๋ฏผํ•ด๋ณด๋ฉด ์ข‹๊ฒ ๋‹ค ์ƒ๊ฐํ•˜๋Š” ๋ถ€๋ถ„์— ๋Œ€ํ•ด ํ”ผ๋“œ๋ฐฑ ๋‚จ๊ฒผ์œผ๋‹ˆ ํ•œ๋ฒˆ ๊ณ ๋ฏผํ•ด ๋ณด๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

## ์ฝ”๋“œ ๋ฆฌ๋ทฐ
> PR ๋งํฌ :
## ๋‚˜์˜ ํ•™์Šต ๋ชฉํ‘œ
Copy link
Contributor

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 ์ „ ํ™•์ธํ•ด์•ผ๋  ๋ชฉ๋ก
Copy link
Contributor

Choose a reason for hiding this comment

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

๐Ÿ‘

throw new CannotDeleteException("๋‹ค๋ฅธ ์‚ฌ๋žŒ์ด ์“ด ๋‹ต๋ณ€์ด ์žˆ์–ด ์‚ญ์ œํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.");
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

ํ˜„์žฌ๋Š” valid์™€ updateDeleted๊ฐ€ ๋ถ„๋ฆฌ๋˜์–ด ๊ตฌํ˜„๋˜์–ด ์žˆ์Œ.
์ด ๋‘˜์„ ํ•˜๋‚˜๋กœ ๊ตฌํ˜„ํ•˜๋Š” ์•„๋ž˜์™€ ๋น„๊ตํ–ˆ์„ ๋•Œ ์–ด๋А ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด ๋” ์ข‹์„๊นŒ?

Suggested change
public void delete(NsUser loginUser) throws CannotDeleteException {
// ์œ ํšจ์„ฑ ์ฒดํฌ์™€ ์‚ญ์ œ ์ƒํƒœ๋กœ ๋ณ€๊ฒฝ
}

Copy link
Contributor

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 {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public List<DeleteHistory> delete(long questionId) {
public List<DeleteHistory> delete() {

questionid๋Š” Question์ด ๊ฐ€์ง€๊ณ  ์žˆ์Œ.
๊ตณ์ด ํ•„์š”์—†์ง€ ์•Š์„๊นŒ?

}
}

public List<DeleteHistory> delete(long questionId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public List<DeleteHistory> delete(long questionId) {
public void delete(NsUser loginUser) {

Answer ํ”ผ๋“œ๋ฐฑ๊ณผ ๊ฐ™์ด ํ˜„์žฌ ๋‘˜๋กœ ๋ถ„๋ฆฌ๋˜์–ด ์žˆ๋Š” ๊ตฌํ˜„๊ณผ ์œ„์™€ ๊ฐ™์ด ์‚ญ์ œ ๊ถŒํ•œ ์ฒดํฌ์—ฌ๋ถ€์™€ deleted ์ƒํƒœ ๋ณ€๊ฒฝ ๋กœ์ง์„ ํ•จ๊ป˜ ๊ตฌํ˜„ํ•˜๋Š” ์œ„ ์ ‘๊ทผ ๋ฐฉ์‹ ์ค‘ ์–ด๋А ์ ‘๊ทผ ๋ฐฉ์‹์ด ์ข‹์„์ง€ ๊ณ ๋ฏผํ•ด ๋ณด๋ฉด ์–ด๋–จ๊นŒ?


return deleteHistories;
}

Copy link
Contributor

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 ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์„œ๋“œ ๋‘ ๊ฐœ๋กœ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ ์ค‘ ์–ด๋А ์ ‘๊ทผ ๋ฐฉ์‹์ด ์ข‹์„๊นŒ?

}



Copy link
Contributor

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 ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ๋‚ด๋ถ€ ์ˆ˜์ •
@chanani
Copy link
Author

chanani commented Nov 26, 2025

๋ฆฌ๋ทฐํ•ด ์ฃผ์‹  ๊ฒƒ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•ด๋ดค์Šต๋‹ˆ๋‹ค !

ํ•œ ๋ฉ”์„œ๋“œ๋Š” ํ•˜๋‚˜์˜ ์—ญํ• ๋งŒ ํ•ด์•ผ๋œ๋‹ค๋Š” ์ƒ๊ฐ์œผ๋กœ ๊ฒ€์ฆํ•˜๋Š” ๋กœ์ง๊ณผ ์ƒํƒœ๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๋กœ์ง์ด Service(deleteQuestion)์—์„œ ๊ฐ๊ฐ ํ˜ธ์ถœ ๋˜์–ด์•ผ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.

delete() ํ˜ธ์ถœ ํ›„ ํ•ด๋‹น ๋ฉ”์„œ๋“œ ๋‚ด๋ถ€์—์„œ ๊ฒ€์ฆ ๋กœ์ง ๋”ฐ๋กœ, ์ƒํƒœ ๋ณ€๊ฒฝ ๋กœ์ง ๋”ฐ๋กœ ์ง„ํ–‰ํ•˜๊ฒŒ ๋˜๋ฉด, ๋ง์”€ํ•˜์‹  ๊ฒƒ๊ณผ ๊ฐ™์ด delete๋ผ๋Š” ๋ชฉ์ ์— ์•Œ๋งž๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค !

์ถ”๊ฐ€๋กœ ํ”ผ๋“œ๋ฐฑ ์ „ ์ˆ˜์ •ํ•ด ๋†“์€ ๋‚ด์šฉ ์žˆ๋Š”๋ฐ ํ™•์ธ ๋ชปํ•˜์…จ์„ ๊ฒƒ ๊ฐ™์•„ ๋ง์”€๋“œ๋ฆฝ๋‹ˆ๋‹ค !
๊ณต์šฉ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” createdDate, updatedDate, deleted๋ฅผ BaseModel ํด๋ž˜์Šค๋กœ ๋ถ„๋ฆฌํ•˜์—ฌ ์ƒ์† ๋ฐ›๋Š” ๋ฐฉํ–ฅ์œผ๋กœ ์ง„ํ–‰ํ•ด ๋ดค๋Š”๋ฐ ํšจ์œจ์ ์ธ๊ฑด์ง€ ๊ทธ๋ฆฌ๊ณ  public์œผ๋กœ ์„ ์–ธํ•ด ๋†จ๋Š”๋ฐ ๊ดœ์ฐฎ์€์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค !

Copy link
Contributor

@javajigi javajigi left a 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() {
Copy link
Contributor

Choose a reason for hiding this comment

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

์‚ญ์ œ ์ƒํƒœ ๋ณ€๊ฒฝ์— ๋”ฐ๋ฅธ ๊ฒ€์ฆ์„ ํ•˜๋Š” ๊ฒƒ์„ ๊ณ ๋ คํ–ˆ์„ ๋•Œ private์œผ๋กœ ๊ตฌํ˜„ํ•ด์•ผ ์•ˆ์ „ํ•˜์ง€ ์•Š์„๊นŒ?

throw new CannotDeleteException("๋‹ค๋ฅธ ์‚ฌ๋žŒ์ด ์“ด ๋‹ต๋ณ€์ด ์žˆ์–ด ์‚ญ์ œํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.");
}
}

Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void addDeleteAnswerHistory(List<DeleteHistory> deleteHistories) {
public List<DeleteHistory> toDeleteAnswerHistories() {
List<DeleteHistory> deleteHistories = new ArrayList<>();

๊ฐœ์ธ์ ์œผ๋กœ List ์ฝœ๋ ‰์…˜์„ ์ธ์ž๋กœ ์ „๋‹ฌํ•ด ์ €์žฅํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค ์œ„์™€ ๊ฐ™์ด ํ•ด๋‹น ๋ฉ”์„œ๋“œ์—์„œ ์ง์ ‘ ์ƒ์„ฑํ•ด ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒƒ์ด ๋‹ค๋ฅธ ๊ฐ์ฒด์™€์˜ ์˜์กด ๊ด€๊ณ„๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์„ ํ˜ธํ•˜๋Š” ๋ฐฉ๋ฒ•์ž„


import java.time.LocalDateTime;

public abstract class BaseModel {
Copy link
Contributor

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์—๊ฒŒ ํ”„๋กœ์ ํŠธ์˜ ์ •์ฑ…์„ ์„ค๋ช…ํ•˜๊ณ  ๋” ์ ํ•ฉํ•œ ์ด๋ฆ„์„ ์ถ”์ฒœ ๋ฐ›์•„๋ณธ๋‹ค.

Comment on lines +7 to +11
public LocalDateTime createdDate = LocalDateTime.now();

public LocalDateTime updatedDate;

public boolean deleted = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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์œผ๋กœ ๊ตฌํ˜„

Comment on lines +7 to +11
public LocalDateTime createdDate = LocalDateTime.now();

public LocalDateTime updatedDate;

public boolean deleted = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

์ด ๊ฐ์ฒด๋Š” ๊ฐ’์„ ํฌ์žฅํ•˜๋Š” ๊ฒƒ ์™ธ์— ์•„๋ฌด ๋กœ์ง๋„ ์—†๋Š”๋ฐ ํฌ์žฅํ•˜๋Š” ๊ฒƒ์ด ์˜๋ฏธ์žˆ์„๊นŒ?
Title ๋™์ผ
๋‹จ, title๊ณผ contents๋ฅผ ์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง€๋Š” QuestionBody์™€ ๊ฐ™์€ ๊ฐ์ฒด๋ฅผ ๋ถ„๋ฆฌํ•œ๋‹ค๋ฉด ์˜๋ฏธ์žˆ์„๊นŒ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants