Skip to content

Commit

Permalink
#45 - 수정, 삭제 할 때 해당 사용자가 맞는지 확인하기 위해 응답 정보 추가
Browse files Browse the repository at this point in the history
인증 정보의 `userId`와 해당 게시글/댓글dml 작성자 `userId`를 비교하기 위해 responseDto 에 userId 추가
  • Loading branch information
GGHDMS committed Feb 13, 2023
1 parent 968f24c commit 0c96949
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ public class ArticleCommentResponse {
LocalDateTime createdAt;
String email;
String nickname;
String userId;

public ArticleCommentResponse(Long id, String content, LocalDateTime createdAt, String email, String nickname) {
public ArticleCommentResponse(Long id, String content, LocalDateTime createdAt, String email, String nickname, String userId) {
this.id = id;
this.content = content;
this.createdAt = createdAt;
this.email = email;
this.nickname = nickname;
this.userId = userId;
}

public static ArticleCommentResponse of(Long id, String content, LocalDateTime createdAt, String email, String nickname) {
return new ArticleCommentResponse(id, content, createdAt, email, nickname);
public static ArticleCommentResponse of(Long id, String content, LocalDateTime createdAt, String email, String nickname, String userId) {
return new ArticleCommentResponse(id, content, createdAt, email, nickname, userId);
}

public static ArticleCommentResponse from(ArticleCommentDto dto) {
Expand All @@ -37,7 +39,8 @@ public static ArticleCommentResponse from(ArticleCommentDto dto) {
dto.getContent(),
dto.getCreatedAt(),
dto.getUserAccountDto().getEmail(),
nickname
nickname,
dto.getUserAccountDto().getUserId()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ public class ArticleWithCommentsResponse {
LocalDateTime createdAt;
String email;
String nickname;
String userId;

Set<ArticleCommentResponse> articleCommentsResponse;

private ArticleWithCommentsResponse(Long id, String title, String content, String hashtag, LocalDateTime createdAt, String email, String nickname, Set<ArticleCommentResponse> articleCommentsResponse) {
private ArticleWithCommentsResponse(Long id, String title, String content, String hashtag, LocalDateTime createdAt, String email, String nickname, String userId, Set<ArticleCommentResponse> articleCommentsResponse) {
this.id = id;
this.title = title;
this.content = content;
this.hashtag = hashtag;
this.createdAt = createdAt;
this.email = email;
this.nickname = nickname;
this.userId = userId;
this.articleCommentsResponse = articleCommentsResponse;
}

public static ArticleWithCommentsResponse of(Long id, String title, String content, String hashtag, LocalDateTime createdAt, String email, String nickname, Set<ArticleCommentResponse> articleCommentResponses) {
return new ArticleWithCommentsResponse(id, title, content, hashtag, createdAt, email, nickname, articleCommentResponses);
public static ArticleWithCommentsResponse of(Long id, String title, String content, String hashtag, LocalDateTime createdAt, String email, String nickname, String userId, Set<ArticleCommentResponse> articleCommentResponses) {
return new ArticleWithCommentsResponse(id, title, content, hashtag, createdAt, email, nickname, userId, articleCommentResponses);
}

public static ArticleWithCommentsResponse from(ArticleWithCommentsDto dto) {
Expand All @@ -48,6 +51,7 @@ public static ArticleWithCommentsResponse from(ArticleWithCommentsDto dto) {
dto.getCreatedAt(),
dto.getUserAccountDto().getEmail(),
nickname,
dto.getUserAccountDto().getUserId(),
dto.getArticleCommentDtos().stream()
.map(ArticleCommentResponse::from)
.collect(Collectors.toCollection(LinkedHashSet::new))
Expand Down

0 comments on commit 0c96949

Please sign in to comment.