Skip to content

Commit

Permalink
Merge pull request #262 from Wingle-SMWU/fix/익명게시판-사용자-구분-#224
Browse files Browse the repository at this point in the history
Fix/익명게시판 사용자 구분 #224
  • Loading branch information
Lightieey authored Aug 21, 2023
2 parents 4863a98 + 7a8cce9 commit ab0169d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import org.springframework.stereotype.Component;

import kr.co.wingle.common.util.AES256Util;
import kr.co.wingle.community.util.CommunityUtil;
import kr.co.wingle.community.util.ProcessedPersonalInformation;
import kr.co.wingle.profile.ProfileService;
Expand All @@ -25,25 +24,24 @@ public ArticleResponseDto toResponseDto(Article article, List<String> images) {

ArticleResponseDto.ArticleResponseDtoBuilder articleResponseDto = ArticleResponseDto.builder();

if (article != null) {
articleResponseDto.articleId(article.getId());
articleResponseDto.createdTime(article.getCreatedTime());
articleResponseDto.updatedTime(article.getUpdatedTime());
articleResponseDto.content(article.getContent());
articleResponseDto.likeCount(article.getLikeCount());
}
articleResponseDto.articleId(article.getId());
articleResponseDto.createdTime(article.getCreatedTime());
articleResponseDto.updatedTime(article.getUpdatedTime());
articleResponseDto.content(article.getContent());
articleResponseDto.likeCount(article.getLikeCount());

articleResponseDto.userNickname(processedPersonalInformation.getNickname());
List<String> list = images;
if (list != null) {
articleResponseDto.images(new ArrayList<String>(list));
}
articleResponseDto.isMine(processedPersonalInformation.isMine());
articleResponseDto.userId(
AES256Util.encrypt(article.getMember().getId().toString(), article.getId().toString()));
articleResponseDto.userId(processedPersonalInformation.getProcessedMemberId());
articleResponseDto.userImage(profileService.getProfileByMemberId(article.getMember().getId()).getImageUrl());
articleResponseDto.userNation(profileService.getProfileByMemberId(article.getMember().getId()).getNation());
articleResponseDto.userSchoolName(processedPersonalInformation.getSchoolName());

articleResponseDto.forumId(article.getForum().getId());
articleResponseDto.isMine(processedPersonalInformation.isMine());

return articleResponseDto.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.stereotype.Component;

import kr.co.wingle.common.util.AES256Util;
import kr.co.wingle.community.util.CommunityUtil;
import kr.co.wingle.community.util.ProcessedPersonalInformation;
import kr.co.wingle.profile.ProfileService;
Expand All @@ -22,8 +21,7 @@ public CommentResponseDto toResponseDto(Comment comment) {
CommentResponseDto.CommentResponseDtoBuilder commentResponseDto = CommentResponseDto.builder();

commentResponseDto.id(comment.getId());
commentResponseDto.userId(
AES256Util.encrypt(comment.getMember().getId().toString(), comment.getArticle().getId().toString()));
commentResponseDto.userId(processedPersonalInformation.getProcessedMemberId());
commentResponseDto.userNickname(processedPersonalInformation.getNickname());
commentResponseDto.userImage(profileService.getProfileByMemberId(comment.getMember().getId()).getImageUrl());
commentResponseDto.userNation(profileService.getProfileByMemberId(comment.getMember().getId()).getNation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import kr.co.wingle.common.constants.ErrorCode;
import kr.co.wingle.common.exception.NotFoundException;
import kr.co.wingle.common.util.AES256Util;
import kr.co.wingle.community.article.Article;
import kr.co.wingle.community.comment.Comment;
import kr.co.wingle.community.forum.Forum;
import kr.co.wingle.community.forum.ForumCode;
import kr.co.wingle.community.forum.ForumService;
import kr.co.wingle.member.entity.Member;
import kr.co.wingle.member.service.AuthService;
Expand All @@ -32,20 +34,26 @@ public ProcessedPersonalInformation processPersonalInformation(Writing writing)
Profile profile = profileService.getProfileByMemberId(writing.getMember().getId());

Forum forum;
Article article;
if (writing instanceof Article) {
forum = ((Article)writing).getForum();
article = (Article)writing;
} else if (writing instanceof Comment) {
forum = ((Comment)writing).getArticle().getForum();
article = ((Comment)writing).getArticle();
} else {
throw new NotFoundException(ErrorCode.BAD_PARAMETER_TYPE);
}

// 게시판별 작성자명
String nickname = forumService.getNicknameByForum(forum, profile);
// 게시판별 멤버id
Long processedMemberId = forumService.processMemberIdByForum(forum,
writing.getMember().getId());
String processedMemberId = ForumCode.from(forum.getName()).equals(ForumCode.EXCHANGE) ?
AES256Util.encrypt(writing.getMember().getId().toString()) :
AES256Util.encrypt(writing.getMember().getId().toString(), article.getId().toString());
// 게시판별 작성자 학교이름
String schoolName = forumService.getSchoolNameByForum(forum, writing.getMember().getSchool());
String schoolName = writing.getMember().isDeleted() ? "(알수없음)" :
forumService.getSchoolNameByForum(forum, writing.getMember().getSchool());
boolean isMine = writingUtil.isMine(writing);
return ProcessedPersonalInformation.of(nickname, processedMemberId, schoolName, isMine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
@AllArgsConstructor(access = AccessLevel.PROTECTED)
public class ProcessedPersonalInformation {
private String nickname;
private Long processedMemberId;
private String processedMemberId;
private String schoolName;
private boolean isMine;

public static ProcessedPersonalInformation of(String nickname, Long processedMemberId, String schoolName,
public static ProcessedPersonalInformation of(String nickname, String processedMemberId, String schoolName,
boolean isMine) {
return new ProcessedPersonalInformation(nickname, processedMemberId, schoolName, isMine);
}
Expand Down

0 comments on commit ab0169d

Please sign in to comment.