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

πŸš€ 1단계 - λ ˆκ±°μ‹œ μ½”λ“œ λ¦¬νŒ©ν„°λ§ #669

Merged
merged 12 commits into from
Apr 7, 2025

Conversation

selene-p
Copy link

@selene-p selene-p commented Apr 6, 2025

μ•ˆλ…•ν•˜μ„Έμš” πŸ€“
1단계 κ΅¬ν˜„ μ™„λ£Œν•˜μ—¬ PR λ“œλ¦½λ‹ˆλ‹€!
λ§ˆμ§€λ§‰ λ‹¨κ³„κΉŒμ§€ 잘 λΆ€νƒλ“œλ¦½λ‹ˆλ‹· πŸ™‡β€β™€οΈ

πŸ“Œ λ¦¬νŒ©ν„°λ§ λ‚΄μš©

  1. QnaService의 λΉ„μ¦ˆλ‹ˆμŠ€ λ‘œμ§μ„ 도메인 λͺ¨λΈλ‘œ 이동
  • κΈ°μ‘΄ QnaService의 deleteQuestion() λ©”μ„œλ“œκ°€ λ„ˆλ¬΄ λ§Žμ€ λΉ„μ¦ˆλ‹ˆμŠ€ λ‘œμ§μ„ ν¬ν•¨ν•˜κ³  μžˆμ–΄ 이λ₯Ό 도메인 λͺ¨λΈλ‘œ λΆ„λ¦¬ν•˜μ˜€μŠ΅λ‹ˆλ‹€.
  • Question, Answers, Answer, DeleteHistory 도메인 클래슀둜 κΈ°λŠ₯을 μž¬κ΅¬μ„±ν•˜μ˜€μŠ΅λ‹ˆλ‹€.
  • Question이 가지고 μžˆλŠ” List<Answer>λ₯Ό μΌκΈ‰μ»¬λ ‰μ…˜μΈ Answers둜 ν•œλ²ˆ κ°μŒŒμŠ΅λ‹ˆλ‹€.
  1. Question μ—μ„œ λ‹΅λ³€ μ‚­μ œ λ‘œμ§μ„ λͺ¨λ‘ λ‹΄λ‹Ήν•˜λ„λ‘ ν•˜μ—¬ μ±…μž„μ„ λͺ…ν™•νžˆ ν•˜μ˜€μŠ΅λ‹ˆλ‹€.
  • delete() λ©”μ„œλ“œ λ‚΄λΆ€μ—μ„œ createDeleteHistory() λ₯Ό ν˜ΈμΆœν•˜λ„λ‘ ν•˜μ—¬ μ‚­μ œ 기둝 생성이 항상 보μž₯λ˜λ„λ‘ κ΅¬ν˜„ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

🧐 고민 포인트

  • Questionκ³Ό Answer의 delete λ©”μ„œλ“œκ°€ DeleteHistory 객체λ₯Ό λ°˜ν™˜ν•˜λŠ” 것이 μ–΄μƒ‰ν•˜λ‹€κ³  λŠκΌˆλŠ”λ°μš”γ… 
  • λ‹¨μˆœνžˆ μ‚­μ œ λ‘œμ§μ„ μˆ˜ν–‰ν•˜λŠ” λ©”μ„œλ“œκ°€ 데이터λ₯Ό λ°˜ν™˜ν•˜λŠ” 것이 μ’€ μ–΄μƒ‰ν•˜λ‹€λŠ” 생각이 계속 λ“€κΈ΄ ν–ˆμŠ΅λ‹ˆλ‹€...!
  • 그런데 λ§Œμ•½ delete λ©”μ„œλ“œμ™€ DeleteHistory 생성을 λ³„λ„λ‘œ μ²˜λ¦¬ν•˜λ©΄, μ‚¬μš©μžκ°€ delete λ©”μ„œλ“œλ₯Ό ν˜ΈμΆœν•  λ•Œ DeleteHistory 생성을 빠뜨릴 수 μžˆλ‹€λŠ” 문제(?)점이 μžˆμ„ 것 κ°™μ•„μ„œ, DeleteHistory 생성이 보μž₯을 μœ„ν•΄ delete λ©”μ„œλ“œ μ•ˆμ— κ΅¬ν˜„ν•˜κΈ΄ ν–ˆμŠ΅λ‹ˆλ‹€..!

Copy link

@jinyoungchoi95 jinyoungchoi95 left a comment

Choose a reason for hiding this comment

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

μ•ˆλ…•ν•˜μ„Έμš” ν•΄μ›λ‹˜ πŸ˜„

μˆ˜κ°•μ‹ μ²­ λ―Έμ…˜μ˜ 리뷰어λ₯Ό 맑은 μ΅œμ§„μ˜μž…λ‹ˆλ‹€.

λ―Έμ…˜ 잘 μ§„ν–‰ν•΄μ£Όμ…¨λ„€μš”! λͺ‡κ°€μ§€ μ½”λ©˜νŠΈ λ‚¨κ²¨λ‘μ—ˆμœΌλ‹ˆ λ‹€μŒ 단계 μ§„ν–‰ν•˜μ‹œλ©΄μ„œ ν•¨κ»˜ ν™•μΈλΆ€νƒλ“œλ €μš” :)

κΆκΈˆν•˜κ±°λ‚˜ 고민이 λ˜λŠ” 뢀뢄이 μžˆμœΌμ‹œλ‹€λ©΄ μ–Έμ œλ“  pr μ½”λ©˜νŠΈ λ˜λŠ” dm으둜 μš”μ²­ λΆ€νƒλ“œλ¦½λ‹ˆλ‹€.
κ°μ‚¬ν•©λ‹ˆλ‹€ πŸ™‡β€β™‚οΈ

return id;
public DeleteHistory delete() {
this.deleted = true;
return createDeleteHistory();

Choose a reason for hiding this comment

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

λ„€ μ €λŠ” delete 처리의 결과둜 DeleteHistoryλ₯Ό λ°˜ν™˜ν•˜λŠ”κ²Œ 크게 μ–΄μƒ‰ν•΄λ³΄μ΄μ§€λŠ” μ•Šμ•„μš”.

λ©”μ„œλ“œλΆ„λ¦¬κΉŒμ§€λŠ” κ³Όν•˜μ§€ μ•Šλ‚˜λΌλŠ” 생각이 λ“œλ„€μš” πŸ˜„

import java.util.Collections;
import java.util.List;

public class Answers {

Choose a reason for hiding this comment

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

일급 μ»¬λž™μ…˜ 잘 λ§Œλ“€μ–΄μ£Όμ…¨λ„€μš” πŸ‘


public class Answers {

private final List<Answer> answerList;

Choose a reason for hiding this comment

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

λ³΄μœ ν•œ 데이터에 λŒ€ν•΄μ„œ List둜 μžλ£Œν˜•μ„ ν‘œν˜„ν•˜μ§€ μ•Šμ•„λ„ 쒋을 것 κ°™μ•„μš”. κ΄€λ¦¬ν•˜λŠ” λŒ€μƒμ€ answers이고, 이미 νƒ€μž…μ—μ„œ μ–΄λ–€ μžλ£Œν˜•μΈμ§€κ°€ ν‘œν˜„μ΄ λ˜μ–΄μžˆκΈ°λ„ν•˜κ΅¬μš”.

μžλ£Œν˜•μ΄ λ³€κ²½λœλ‹€λ©΄ λ³€μˆ˜λͺ…도 같이 λ°”λ€Œμ–΄μ•Όν•œλ‹€λŠ” 단점도 μžˆκ² λ„€μš” πŸ˜„

Comment on lines +53 to +55
if (!answers.areAllAnswersSameWriter(writer)) {
throw new CannotDeleteException("λ‹€λ₯Έ μ‚¬λžŒμ΄ μ“΄ 닡변이 μžˆμ–΄ μ‚­μ œν•  수 μ—†μŠ΅λ‹ˆλ‹€.");
}

Choose a reason for hiding this comment

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

λ‹΅λ³€ 본인의 μ‚­μ œμ— λŒ€ν•œ μ˜ˆμ™Έμ²˜λ¦¬λŠ” Answer λ‚΄λΆ€μ—μ„œ μ²˜λ¦¬ν•˜μ—¬μ•Όν•˜μ§€ μ•Šμ„κΉŒμš”? :)

answer.setDeleted(true);
deleteHistories.add(new DeleteHistory(ContentType.ANSWER, answer.getId(), answer.getWriter(), LocalDateTime.now()));
}
List<DeleteHistory> deleteHistories = question.delete(loginUser);

Choose a reason for hiding this comment

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

κΉ”λ”ν•˜κ²Œ 잘 μ²˜λ¦¬λ˜μ—ˆλ„€μš” πŸ‘

@jinyoungchoi95 jinyoungchoi95 merged commit d8925be into next-step:selene-p Apr 7, 2025
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