diff --git a/src/main/generated/com/example/just/Dao/QPostLike.java b/src/main/generated/com/example/just/Dao/QPostLike.java new file mode 100644 index 00000000..a03a11f4 --- /dev/null +++ b/src/main/generated/com/example/just/Dao/QPostLike.java @@ -0,0 +1,54 @@ +package com.example.just.Dao; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QPostLike is a Querydsl query type for PostLike + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QPostLike extends EntityPathBase { + + private static final long serialVersionUID = -993289340L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QPostLike postLike = new QPostLike("postLike"); + + public final NumberPath id = createNumber("id", Long.class); + + public final QMember member; + + public final QPost post; + + public QPostLike(String variable) { + this(PostLike.class, forVariable(variable), INITS); + } + + public QPostLike(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QPostLike(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QPostLike(PathMetadata metadata, PathInits inits) { + this(PostLike.class, metadata, inits); + } + + public QPostLike(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.member = inits.isInitialized("member") ? new QMember(forProperty("member")) : null; + this.post = inits.isInitialized("post") ? new QPost(forProperty("post"), inits.get("post")) : null; + } + +} + diff --git a/src/main/java/com/example/just/Admin/AdminController.java b/src/main/java/com/example/just/Admin/AdminController.java index b302bbb7..4c61b362 100644 --- a/src/main/java/com/example/just/Admin/AdminController.java +++ b/src/main/java/com/example/just/Admin/AdminController.java @@ -16,6 +16,7 @@ import com.example.just.Service.*; import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Operation; +import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.crossstore.ChangeSetPersister.NotFoundException; @@ -129,12 +130,15 @@ public ResponseEntity> PostList() { @ApiOperation(value = "포스트페이지에서 포스트 삭제 ") @Operation(summary = "게시글 삭제", description = "\n post_id 헤더로 받고 데이터베이스 비교 후 회원 삭제") @DeleteMapping("/posts/{post_id}") - public ResponsePost deletePost(@PathVariable Long post_id) throws NotFoundException { + public ResponsePost deletePost(@PathVariable Long post_id, HttpServletRequest request) throws NotFoundException { + postService.deletePost(post_id); ResponsePost responsePost = new ResponsePost(post_id, "삭제 완료"); return responsePost; } + + @ApiOperation(value = "포스트페이지 해시태그 수정 ") @Operation(summary = "해시태그 수정", description = "\n hashtag_id 헤더로 받고 내용을 수정하면 새로운 해시태그를 생성하여 저장 ex) id_101 -> id_104로") @PutMapping("/hashtags/{hashtag_id}") diff --git a/src/main/java/com/example/just/Controller/CommentController.java b/src/main/java/com/example/just/Controller/CommentController.java index 8b154d74..5fe0a012 100644 --- a/src/main/java/com/example/just/Controller/CommentController.java +++ b/src/main/java/com/example/just/Controller/CommentController.java @@ -79,12 +79,12 @@ public ResponseEntity createComment(@PathVariable Long post_ member_id = Long.valueOf(jwtProvider.getIdFromToken(token)); //토큰 comment = commentService.createComment(post_id, member_id, comment_dto); - } catch (NullPointerException e){ + } catch (NullPointerException e) { return ResponseEntity.status(404).body(new ResponseCommentDto("해당 부모 댓글 없음")); - } catch (RuntimeException e){ + } catch (RuntimeException e) { return ResponseEntity.status(404).body(new ResponseCommentDto("대댓글에는 대댓글 작성 불가")); } - return ResponseEntity.ok(new ResponseCommentDto(comment,member_id,"입력 완료")); + return ResponseEntity.ok(new ResponseCommentDto(comment, member_id, "입력 완료")); } @ApiOperation(value = "댓글 조회 API") @@ -102,20 +102,24 @@ public ResponseEntity getCommentListBefore(@PathVa @Operation(summary = "댓글 삭제 api", description = "대댓글까지 다 삭제되니 유의해야 함") @DeleteMapping("/delete/comment/{post_id}/{comment_id}") - public ResponseEntity deleteComment(@PathVariable Long post_id, @PathVariable Long comment_id) { - return commentService.deleteComment(post_id, comment_id); + public ResponseEntity deleteComment(@PathVariable Long post_id, @PathVariable Long comment_id, + HttpServletRequest request) { + Long member_id = getAccessTokenOfMemberId(request); + return commentService.deleteComment(post_id, comment_id, member_id); } + @ApiOperation(value = "댓글 수정") @ApiResponses(value = { - @ApiResponse(responseCode = "200",description = "댓글 내용"), - @ApiResponse(responseCode = "400",description = "댓글이 존재하지 않습니다.\n게시물이 존재하지 않습니다.") + @ApiResponse(responseCode = "200", description = "댓글 내용"), + @ApiResponse(responseCode = "400", description = "댓글이 존재하지 않습니다.\n게시물이 존재하지 않습니다.") }) @PutMapping("/put/comment/{post_id}/{comment_id}") public ResponseEntity putComment(@PathVariable Long post_id, @PathVariable Long comment_id, @RequestBody PutCommentDto commentDto, - HttpServletRequest req) { - return commentService.putComment(post_id, comment_id, commentDto); + HttpServletRequest request) { + Long member_id = getAccessTokenOfMemberId(request); + return commentService.putComment(post_id, comment_id, commentDto, member_id); } @ApiOperation(value = "댓글 신고") @@ -153,7 +157,7 @@ public ResponseEntity getMyComment(HttpServletRequest request) { return commentService.getMyComment(member_id); } - private String errorMassage(String error){ + private String errorMassage(String error) { return "{\n" + " \"comment_id\": \"\",\n" + " \"comment_create_time\": 0\n" @@ -165,4 +169,10 @@ private String errorMassage(String error){ + " \"message\": \"성공\"\n" + "}"; } + + private Long getAccessTokenOfMemberId(HttpServletRequest request) { + String token = jwtProvider.getAccessToken(request); + Long member_id = Long.valueOf(jwtProvider.getIdFromToken(token)); //토큰 + return member_id; + } } diff --git a/src/main/java/com/example/just/Controller/PostController.java b/src/main/java/com/example/just/Controller/PostController.java index 1c36c7ce..69a53925 100644 --- a/src/main/java/com/example/just/Controller/PostController.java +++ b/src/main/java/com/example/just/Controller/PostController.java @@ -45,7 +45,6 @@ public ResponseEntity getPosts(@RequestParam Long request_page, @Operation(summary = "자기의 게시글을 조회하는 API", description = " 자신의 게시글을 조회한다") @GetMapping("/get/mypost") public ResponseEntity getMyPosts(HttpServletRequest request) throws NotFoundException { - Long member_id = getAccessTokenOfMemberId(request); try { return ResponseEntity.ok(postService.getMyPost(member_id)); @@ -61,7 +60,6 @@ public ResponseEntity getMyPosts(HttpServletRequest request) throws NotF public ResponseEntity getMemberPosts(@RequestParam Long request_page, HttpServletRequest request) { String cursor = request.getHeader("viewed"); Long member_id = getAccessTokenOfMemberId(request); - String like = request.getHeader("like"); try { return ResponseEntity.ok(postService.searchByCursorMember(cursor, request_page, member_id)); } catch (NotFoundException e) { @@ -92,9 +90,11 @@ public PostPostDto write(HttpServletRequest request, @Operation(summary = "게시글 삭제 api", description = "\n 글이 삭제되면 value : 삭제 완료" + "\n 글이 없으면 value : 글이 없습니다.") @DeleteMapping("/delete/post") - public ResponseEntity deletePost(@RequestParam Long post_id) throws NotFoundException { + public ResponseEntity deletePost(@RequestParam Long post_id, HttpServletRequest request) + throws NotFoundException { + Long member_id = getAccessTokenOfMemberId(request); try { - postService.deletePost(post_id); + postService.deletePost(post_id, member_id); return ResponseEntity.ok("삭제 완료"); } catch (NotFoundException e) { return ResponseEntity.notFound().build(); diff --git a/src/main/java/com/example/just/Dao/PostLike.java b/src/main/java/com/example/just/Dao/PostLike.java new file mode 100644 index 00000000..553b46ee --- /dev/null +++ b/src/main/java/com/example/just/Dao/PostLike.java @@ -0,0 +1,33 @@ +package com.example.just.Dao; + +import javax.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Entity +@Table(name = "post_like") +@Getter +@Setter +@NoArgsConstructor +public class PostLike { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "post_id") + private Post post; + + @ManyToOne + @JoinColumn(name = "member_id") + private Member member; + + public PostLike(Post post, Member member) { + this.post = post; + this.member = member; + + } + +} diff --git a/src/main/java/com/example/just/Repository/PostLikeRepository.java b/src/main/java/com/example/just/Repository/PostLikeRepository.java new file mode 100644 index 00000000..5dd5c7db --- /dev/null +++ b/src/main/java/com/example/just/Repository/PostLikeRepository.java @@ -0,0 +1,13 @@ +package com.example.just.Repository; + +import com.example.just.Dao.Member; +import com.example.just.Dao.Post; +import com.example.just.Dao.PostLike; +import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PostLikeRepository extends JpaRepository { + PostLike findByPostAndMember(Post post, Member member); + + List findByMember(Member member); +} diff --git a/src/main/java/com/example/just/Response/ResponseGetMemberPostDto.java b/src/main/java/com/example/just/Response/ResponseGetMemberPostDto.java index aaf06b44..9c9d0553 100644 --- a/src/main/java/com/example/just/Response/ResponseGetMemberPostDto.java +++ b/src/main/java/com/example/just/Response/ResponseGetMemberPostDto.java @@ -48,19 +48,14 @@ public ResponseGetMemberPostDto(Post post, Long member_id, Member member) { this.post_like_size = post.getPost_like(); this.blamed_count = Math.toIntExact(post.getBlamedCount()); this.like = false; - for (int i = 0; i < post.getLikedMembers().size(); i++) { - System.out.println(post.getLikedMembers().get(i).getId()); - if (post.getLikedMembers().get(i).getId() == member_id) { - - this.like = true; - break; - } + if (member.getLikedPosts().contains(post)) { + this.like = true; } } - public ResponseGetMemberPostDto(List results, Long member_id, int i, List hashTagMaps) { - + public ResponseGetMemberPostDto(List results, Long member_id, int i, List hashTagMaps, + Member member) { this.post_id = results.get(i).getPost_id(); this.post_content = results.get(i).getPostContent(); this.post_picture = results.get(i).getPost_picture(); @@ -81,6 +76,10 @@ public ResponseGetMemberPostDto(List results, Long member_id, int i, List< this.mine = false; } } - + if (member.getLikedPosts().stream().anyMatch(post -> post.getPost_id().equals(results.get(i).getPost_id()))) { + this.like = true; + } else { + this.like = false; + } } } \ No newline at end of file diff --git a/src/main/java/com/example/just/Service/CommentService.java b/src/main/java/com/example/just/Service/CommentService.java index f96573ad..3753e918 100644 --- a/src/main/java/com/example/just/Service/CommentService.java +++ b/src/main/java/com/example/just/Service/CommentService.java @@ -61,7 +61,7 @@ public Comment createComment(Long postId, Long member_id, CommentDto commentDto) if (commentDto.getParent_comment_id() != null && commentDto.getParent_comment_id() != 0) { parentComment = commentRepository.findById(commentDto.getParent_comment_id()) .orElseThrow(() -> new NullPointerException("부모 댓글이 존재하지 않습니다.")); - if(parentComment.getParent() != null){ + if (parentComment.getParent() != null) { throw new RuntimeException("해당 댓글에는 대댓글을 작성할 수 없습니다."); } } @@ -113,7 +113,7 @@ public ResponsePostCommentDto getCommentList(Long postId, HttpServletRequest req if (post != null && post.getComments() != null) { comments = post.getComments().stream() .filter(comment -> comment.getParent() == null) - .map(comment -> new ResponseCommentDto(comment, member_id,"")) + .map(comment -> new ResponseCommentDto(comment, member_id, "")) .collect(Collectors.toList()); } @@ -137,32 +137,43 @@ public ResponsePostCommentDtoBefore getCommentListBefore(Long postId, HttpServle return new ResponsePostCommentDtoBefore(post.getPostContent(), comments); } - public ResponseEntity deleteComment(Long postId, Long commentId) { + public ResponseEntity deleteComment(Long postId, Long commentId, Long member_id) { Post post = postRepository.findById(postId) .orElseThrow(() -> new RuntimeException("게시물이 존재하지 않습니다.")); Comment comment = commentRepository.findById(commentId) .orElseThrow(() -> new RuntimeException("부모 댓글이 존재하지 않습니다.")); - comment.setChildren(null); - PostDocument postDocument = postContentESRespository.findById(postId).get(); - postDocument.setCommentSize(postDocument.getCommentSize() - 1); - postContentESRespository.save(postDocument); - commentRepository.deleteById(commentId); - return ResponseEntity.ok("ok"); + if (comment.getMember().getId() == member_id) { + comment.setChildren(null); + PostDocument postDocument = postContentESRespository.findById(postId).get(); + postDocument.setCommentSize(postDocument.getCommentSize() - 1); + postContentESRespository.save(postDocument); + commentRepository.deleteById(commentId); + return ResponseEntity.ok("ok"); + } else { + return ResponseEntity.status(403).body("권한이 없습니다."); + } } public ResponseEntity putComment(Long postId, Long commentId, - PutCommentDto commentDto) { + PutCommentDto commentDto, Long member_id) { Comment comment = commentRepository.findById(commentId).get(); - if(comment == null) ResponseEntity.status(404).body("댓글이 존재하지 않습니다."); + if (comment == null) { + ResponseEntity.status(404).body("댓글이 존재하지 않습니다."); + } Post post = postRepository.findById(postId).get(); - if(post == null) ResponseEntity.status(404).body("게시물이 존재하지 않습니다."); - - comment.setComment_content(commentDto.getComment_content()); - // 업데이트된 댓글을 저장합니다. - commentRepository.save(comment); + if (post == null) { + ResponseEntity.status(404).body("게시물이 존재하지 않습니다."); + } + if (comment.getMember().getId() == member_id) { + comment.setComment_content(commentDto.getComment_content()); + // 업데이트된 댓글을 저장합니다. + commentRepository.save(comment); - return ResponseEntity.ok(comment.getComment_content()); + return ResponseEntity.ok(comment.getComment_content()); + } else { + return ResponseEntity.status(403).body("권한이 없습니다."); + } } public ResponseEntity blameComment(Long postId, Long commentId) { diff --git a/src/main/java/com/example/just/Service/PostService.java b/src/main/java/com/example/just/Service/PostService.java index d43d8aa9..2718fe94 100644 --- a/src/main/java/com/example/just/Service/PostService.java +++ b/src/main/java/com/example/just/Service/PostService.java @@ -7,6 +7,7 @@ import com.example.just.Dao.Post; +import com.example.just.Dao.PostLike; import com.example.just.Dao.QBlame; import com.example.just.Dao.QHashTag; import com.example.just.Dao.QHashTagMap; @@ -20,6 +21,7 @@ import com.example.just.Repository.HashTagESRepository; import com.example.just.Repository.HashTagMapRepository; +import com.example.just.Repository.PostLikeRepository; import com.example.just.Response.ResponseGetMemberPostDto; import com.example.just.Response.ResponsePutPostDto; import com.example.just.Mapper.PostMapper; @@ -78,6 +80,8 @@ public class PostService { private JwtProvider jwtProvider; @Autowired private GptService gptService; + @Autowired + private PostLikeRepository postLikeRepository; @Autowired PostContentESRespository postContentESRespository; @@ -176,25 +180,29 @@ public ResponsePutPostDto putPost(Long member_id, PutPostDto postDto) throws Not Long post_id = postDto.getPost_id(); Member member = checkMember(member_id); Post checkPost = checkPost(post_id); - List hashTagMaps = checkPost.getHashTagMaps(); + if (checkPost.getMember().getId().equals(member_id)) { + List hashTagMaps = checkPost.getHashTagMaps(); - deleteHashTag(checkPost); + deleteHashTag(checkPost); - List content = new ArrayList<>(); - for (int i = 0; i < postDto.getPost_content().size(); i++) { - content.add(getConvertString(postDto.getPost_content().get(i))); - } - postDto.setPost_content(content); + List content = new ArrayList<>(); + for (int i = 0; i < postDto.getPost_content().size(); i++) { + content.add(getConvertString(postDto.getPost_content().get(i))); + } + postDto.setPost_content(content); - checkPost.changePost(postDto, member, checkPost); + checkPost.changePost(postDto, member, checkPost); - Post p = postRepository.save(checkPost); - saveHashTag(postDto.getHash_tage(), p); + Post p = postRepository.save(checkPost); + saveHashTag(postDto.getHash_tage(), p); - postContentESRespository.save(new PostDocument(checkPost)); + postContentESRespository.save(new PostDocument(checkPost)); - ResponsePutPostDto responsePutPostDto = new ResponsePutPostDto(p); - return responsePutPostDto; + ResponsePutPostDto responsePutPostDto = new ResponsePutPostDto(p); + return responsePutPostDto; + } else { + throw new NotFoundException(); + } } private void deleteHashTag(Post post) { @@ -222,6 +230,7 @@ public List getAllPostList() { public ResponseGetPost searchByCursor(String cursor, Long limit, Long member_id) throws NotFoundException { //글 조 QPost post = QPost.post; QBlame blame = QBlame.blame; + Member member = checkMember(member_id); Set viewedPostIds = new HashSet<>(); // 이전에 본 글들의 ID를 가져옵니다. if (cursor != null) { @@ -241,7 +250,7 @@ public ResponseGetPost searchByCursor(String cursor, Long limit, Long member_id) if (results.size() == 0) { throw new NotFoundException(); } else { - List getPostDtos = createResponseGetMemberPostDto(results, member_id); + List getPostDtos = createResponseGetMemberPostDto(results, member_id, member); return resultPostIds(viewedPostIds, results, getPostDtos); } } @@ -259,12 +268,13 @@ private ResponseGetPost resultPostIds(Set viewedPostIds, List result return responseGetPost; } - private List createResponseGetMemberPostDto(List results, Long member_id) { + private List createResponseGetMemberPostDto(List results, Long member_id, + Member member) { List getPostDtos = new ArrayList<>(); for (int i = 0; i < results.size(); i++) { List hashTagMaps = results.get(i).getHashTagMaps(); ResponseGetMemberPostDto responseGetMemberPostDto = new ResponseGetMemberPostDto(results, member_id, i, - hashTagMaps); + hashTagMaps, member); getPostDtos.add(responseGetMemberPostDto); } return getPostDtos; @@ -288,18 +298,23 @@ public ResponseEntity postLikes(Long post_id, Long member_id) throws NotFound Post post = checkPost(post_id); Member member = checkMember(member_id); + PostLike postLike = postLikeRepository.findByPostAndMember(post, member); ResponsePost responsePost; PostDocument postDocument = postContentESRespository.findById(post_id).get(); - if (member.getLikedPosts().contains(post)) { - post.removeLike(member); + + if (postLike != null) { + post.setPost_like(post.getPost_like() - 1); + postLikeRepository.deleteById(postLike.getId()); postDocument.setPostLikeSize(postDocument.getPostLikeSize() - 1); responsePost = new ResponsePost(post_id, "좋아요 취소"); } else { - post.addLike(member); + post.setPost_like(post.getPost_like() + 1); + postLikeRepository.save(new PostLike(post, member)); postDocument.setPostLikeSize(postDocument.getPostLikeSize() + 1); responsePost = new ResponsePost(post_id, "좋아요 완료"); } + postContentESRespository.save(postDocument); Post savePost = postRepository.save(post); @@ -321,16 +336,15 @@ public ResponseGetPost searchByCursorMember(String cursor, Long limit, Long memb } List posts = postRepository.findAll(); List likePostHashTagName = getLikeHashTag(member_id); - Optional member = memberRepository.findById(member_id); - Member realMember = member.get(); + Member member = checkMember(member_id); List blames = query.select(blame.targetPostId) .from(blame) - .where(blame.blameMemberId.eq(realMember.getId())) + .where(blame.blameMemberId.eq(member.getId())) .fetch(); List targetMembers = query.select(blame.targetMemberId) .from(blame) - .where(blame.blameMemberId.eq(realMember.getId())) + .where(blame.blameMemberId.eq(member.getId())) .fetch(); HttpClient httpClient = HttpClients.createDefault(); @@ -351,30 +365,40 @@ public ResponseGetPost searchByCursorMember(String cursor, Long limit, Long memb // 응답 코드 확인 int statusCode = response.getStatusLine().getStatusCode(); System.out.println("Response Code: " + statusCode); - - // 응답 데이터 읽기 - String responseBody = EntityUtils.toString(response.getEntity()); - System.out.println("Response: " + responseBody);//Response: [[3], [1], [1], [1]] - // 여기서 Python Server의 추천 시스템으로 Post_id들을 가져온다. - List postIds = new ArrayList<>(); - for (int i = 2; i < responseBody.length(); i += 5) { - postIds.add(Long.parseLong(responseBody.substring(i, i + 1))); + if (statusCode == 200) { + + // 응답 데이터 읽기 + String responseBody = EntityUtils.toString(response.getEntity()); + + // 여기서 Python Server의 추천 시스템으로 Post_id들을 가져온다. + List postIds = new ArrayList<>(); + for (int i = 2; i < responseBody.length(); i += 5) { + postIds.add(Long.parseLong(responseBody.substring(i, i + 1))); + } + + results = query.select(post) + .from(post) + .where(post.post_id.notIn(viewedPostIds), + post.post_create_time.isNotNull(), + post.post_id.notIn(blames), + post.member.id.notIn(targetMembers), + post.post_id.in(postIds)) + .orderBy(Expressions.numberTemplate(Double.class, "function('rand')").asc()) + .limit(limit) + .fetch(); + } else { + results = query.select(post) + .from(post) + .where(post.post_id.notIn(viewedPostIds), + post.post_create_time.isNotNull(), + post.post_id.notIn(blames), + post.member.id.notIn(targetMembers)) + .orderBy(Expressions.numberTemplate(Double.class, "function('rand')").asc()) + .limit(limit) + .fetch(); } - System.out.println(postIds); - - results = query.select(post) - .from(post) - .where(post.post_id.notIn(viewedPostIds), - post.post_create_time.isNotNull(), - post.post_id.notIn(blames), - post.member.id.notIn(targetMembers), - post.post_id.in(postIds)) - .orderBy(Expressions.numberTemplate(Double.class, "function('rand')").asc()) - .limit(limit) - .fetch(); } else { - // 예외 처리 또는 기본값 할당 - randomIndex = -1; // 예시로 -1을 할당했으나, 실제 상황에 맞게 수정해야 함 + results = query.select(post) .from(post) .where(post.post_id.notIn(viewedPostIds), @@ -390,17 +414,16 @@ public ResponseGetPost searchByCursorMember(String cursor, Long limit, Long memb if (results.size() == 0) { return (ResponseGetPost) getPostDtos; } else { - getPostDtos = createResponseGetMemberPostDto(results, member_id); + getPostDtos = createResponseGetMemberPostDto(results, member_id, member); // 가져온 글들의 ID를 저장합니다. return resultPostIds(viewedPostIds, results, getPostDtos); } } public List getMyPost(Long member_id) throws NotFoundException { - Optional member = memberRepository.findById(member_id); - Member realMember = member.get(); + Member member = checkMember(member_id); - List results = realMember.getPosts(); + List results = member.getPosts(); // results를 최신 순으로 정렬 Collections.sort(results, Comparator.comparing(Post::getPost_create_time).reversed()); @@ -408,7 +431,7 @@ public List getMyPost(Long member_id) throws NotFoundE if (results.size() == 0) { throw new NotFoundException(); } else { - getPostDtos = createResponseGetMemberPostDto(results, member_id); + getPostDtos = createResponseGetMemberPostDto(results, member_id, member); } return getPostDtos; } @@ -418,7 +441,7 @@ public List getLikeMemberPost(Long member_id) throws N List results = member.getLikedPosts(); // results를 최신 순으로 정렬 Collections.sort(results, Comparator.comparing(Post::getPost_create_time).reversed()); - List getPostDtos = createResponseGetMemberPostDto(results, member_id); + List getPostDtos = createResponseGetMemberPostDto(results, member_id, member); return getPostDtos; } @@ -460,7 +483,8 @@ public List getLikeHashTag(Long member_id) { QHashTagMap hashTagMap = QHashTagMap.hashTagMap; QHashTag hashTag = QHashTag.hashTag; Member member = checkMember(member_id); - //회웡니 쓴글 다 가져오기 + + //회웡니 쓴 글 다 가져오기 List posts = member.getPosts(); //회원이 좋아요 한글의 해시태그 ID 가져오기 @@ -483,7 +507,7 @@ public List getLikeHashTag(Long member_id) { hashTagMaps.add(hashTagMapsOfLike.get(i)); } - //해시태그맵의 ID랑 겹치는거 뽑아오기 + //좋아요 한 글 쓴 글의 해시태그맵의 ID랑 겹치는거 뽑아오기 List hashTags = query.select(hashTag.name) .from(hashTag) .where(hashTag.id.in(hashTagMaps))