-
Notifications
You must be signed in to change notification settings - Fork 26
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
[BE4] 장세계 #19
base: main
Are you sure you want to change the base?
[BE4] 장세계 #19
Conversation
private LocalDateTime createDate; | ||
|
||
@OneToMany(mappedBy = "question", cascade = CascadeType.REMOVE) | ||
private List<Answer> answerList; | ||
|
||
@ManyToOne | ||
private SiteUser author; | ||
|
||
private LocalDateTime modifyDate; | ||
|
||
@ManyToMany | ||
Set<SiteUser> voter; // set은 중복데이터 불가 | ||
|
||
@OneToMany(mappedBy = "question", cascade = CascadeType.REMOVE) | ||
private List<Comment> commentList; | ||
|
||
@ManyToOne | ||
private Category category; | ||
|
||
@Column(columnDefinition = "integer default 0", nullable = false) | ||
private int view; |
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.
상위 엔티티에 대한 필드, 날짜에 대한 필드, 자식들에 대한 필드는 서로 관련있는 것끼리 정렬되면 더 보기 좋겠습니다.
if (question.isPresent()) { | ||
return question.get(); | ||
} else{ | ||
throw new DataNotFoundException("question not found"); | ||
} |
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.
옵셔널을 if로 체크하는 부분이 많이 보이는데 orElseThrow나 orElseGet으로 처리하면 더 깔끔해 보일 것 같습니다.
public void plusView(Question question) { | ||
question.setView(question.getView() + 1); | ||
this.questionRepository.save(question); | ||
} |
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.
plus라는 네이밍이 완전 틀린것은 아니지만 add나 increase 처럼 동사로 시작하는 편이 좋을 것 같습니다
전체적으로 잘해주셨고, main패키지안에 main이 중복으로 들어가있네요, 파일 정리가 필요해보입니다. |
pr이 close 되어 다시올립니다!