-
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] 황인우 #16
base: main
Are you sure you want to change the base?
[BE4] 황인우 #16
Conversation
public static void permission(Object object, String username, HttpMethod httpMethod) { | ||
SiteUser author; | ||
|
||
if(object instanceof Question) { | ||
Question question = (Question) object; | ||
author = question.getAuthor(); | ||
} else if(object instanceof Answer) { | ||
Answer answer = (Answer) object; | ||
author = answer.getAuthor(); | ||
} else if(object instanceof Comment) { | ||
Comment comment = (Comment) object; | ||
author = comment.getAuthor(); | ||
} else { | ||
throw new IllegalArgumentException("잘못된 데이터 타입입니다."); | ||
} | ||
|
||
if(!author.getUsername().equals(username)){ | ||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "%s권한이 없습니다.".formatted(httpMethod.getValue())); | ||
} |
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.
Object대신 BaseEntity타입을 받았다면 당장은 간결한 코드로 만들 수 있었을 것 같은데, 확장성을 위해서인가요?
private Integer questionId; | ||
|
||
private Integer parentId; |
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 String content; | ||
|
||
private LocalDateTime createDate; | ||
|
||
@ManyToOne | ||
private SiteUser author; | ||
|
||
private LocalDateTime modifyDate; | ||
} |
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.
변수를 관련있는 순으로 정렬 하는 걸 추천드립니다. ex) author, content, createDate, modifyDate순
|
||
// 임시 비밀번호 발송 | ||
System.out.println("임시 비밀번호 생성 : " + tempPassword); | ||
this.emailService.sendTempPassword(user.getEmail(), tempPassword); |
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.
이메일 송신은 비동기 처리를 하는 것이 좋아보입니다.
새로운 기능 구현 커밋 전에 기본 상태를 한번 커밋 해놓으면 변경 상태를 확인하기 더 좋겠네요..! 다음부턴 그렇게 해야겠습니다ㅎㅎㅎ