Skip to content

Commit

Permalink
[fix] PR 충돌 오류 해결 (댓글 기능)
Browse files Browse the repository at this point in the history
  • Loading branch information
ms1011 committed Apr 11, 2024
1 parent e2f41b8 commit dee3de3
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 455 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package org.omoknoone.onionhotsayyo.comment.command.aggregate;

import java.time.LocalDateTime;
import java.time.LocalTime;

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@ToString
@Entity
@Table(name="comment")
public class Comment {
Expand All @@ -38,94 +35,9 @@ public class Comment {
@Column(name = "is_deleted")
private boolean isDeleted;

@JoinColumn(name = "posting_id")
@ManyToOne
private Post postingId;

@JoinColumn(name = "member_id")
@ManyToOne
private Member memberId;

public Comment() {
}

public Comment(int commentId, String content, LocalDateTime postedDate, LocalDateTime lastModifiedDate,
boolean isDeleted, Post postingId, Member memberId) {
this.commentId = commentId;
this.content = content;
this.postedDate = postedDate;
this.lastModifiedDate = lastModifiedDate;
this.isDeleted = isDeleted;
this.postingId = postingId;
this.memberId = memberId;
}

public int getCommentId() {
return commentId;
}

public void setCommentId(int commentId) {
this.commentId = commentId;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public LocalDateTime getPostedDate() {
return postedDate;
}

public void setPostedDate(LocalDateTime postedDate) {
this.postedDate = postedDate;
}

public LocalDateTime getLastModifiedDate() {
return lastModifiedDate;
}

public void setLastModifiedDate(LocalDateTime lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}

public boolean isDeleted() {
return isDeleted;
}

public void setDeleted(boolean deleted) {
isDeleted = deleted;
}

public Post getPostingId() {
return postingId;
}

public void setPostingId(Post postingId) {
this.postingId = postingId;
}

public Member getMemberId() {
return memberId;
}

public void setMemberId(Member memberId) {
this.memberId = memberId;
}
@Column(name = "post_id")
private Integer postId;

@Override
public String toString() {
return "Comment{" +
"commentId=" + commentId +
", content='" + content + '\'' +
", postedDate=" + postedDate +
", lastModifiedDate=" + lastModifiedDate +
", isDeleted=" + isDeleted +
", postingId=" + postingId +
", memberId=" + memberId +
'}';
}
@Column(name = "member_id")
private String memberId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void removeComment(@PathVariable("commentId") int commentid) {
/* 내가 작성한 댓글(+대댓글) 목록 조회 */
@GetMapping("/list/mycomments/{memberId}")
public ResponseEntity<List<CommentReplyDTO>> viewCommentListByMe(@PathVariable("memberId") String memberId) {
System.out.println("[controller] memberId = " + memberId);
List<CommentReplyDTO> comments = commentService.viewCommentListByMe(memberId);
return new ResponseEntity<>(comments, HttpStatus.OK);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package org.omoknoone.onionhotsayyo.comment.command.dto;

import java.time.LocalDateTime;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import lombok.*;

import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.time.LocalDateTime;

@AllArgsConstructor
@NoArgsConstructor
@Getter @Setter
@ToString
public class CommentDTO {

private int commentId;
Expand All @@ -24,90 +20,10 @@ public class CommentDTO {

private boolean isDeleted;

private Post postingId;

private Member memberId;

public CommentDTO() {
}

public CommentDTO(int commentId, String content, LocalDateTime postedDate, LocalDateTime lastModifiedDate,
boolean isDeleted, Post postingId, Member memberId) {
this.commentId = commentId;
this.content = content;
this.postedDate = postedDate;
this.lastModifiedDate = lastModifiedDate;
this.isDeleted = isDeleted;
this.postingId = postingId;
this.memberId = memberId;
}

public int getCommentId() {
return commentId;
}

public void setCommentId(int commentId) {
this.commentId = commentId;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public LocalDateTime getPostedDate() {
return postedDate;
}

public void setPostedDate(LocalDateTime postedDate) {
this.postedDate = postedDate;
}

public LocalDateTime getLastModifiedDate() {
return lastModifiedDate;
}

public void setLastModifiedDate(LocalDateTime lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}

public boolean isDeleted() {
return isDeleted;
}

public void setDeleted(boolean deleted) {
isDeleted = deleted;
}

public Post getPostingId() {
return postingId;
}

public void setPostingId(Post postingId) {
this.postingId = postingId;
}
private Integer postId;

public Member getMemberId() {
return memberId;
}
private String memberId;

public void setMemberId(Member memberId) {
this.memberId = memberId;
}
private String nickname; // 필요없으면 지움

@Override
public String toString() {
return "CommentDTO{" +
"commentId=" + commentId +
", content='" + content + '\'' +
", postedDate=" + postedDate +
", lastModifiedDate=" + lastModifiedDate +
", isDeleted=" + isDeleted +
", postingId=" + postingId +
", memberId=" + memberId +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,76 +1,21 @@
package org.omoknoone.onionhotsayyo.comment.command.dto;

import lombok.*;

import java.time.LocalDateTime;

@AllArgsConstructor
@NoArgsConstructor
@Getter @Setter
@ToString
/* 내가 작성한 댓글 + 대댓글 조회 시 필요한 댓글 대댓글 DTO */
public class CommentReplyDTO {

private String memberId;
private String nickname;
private String content;
private LocalDateTime postedDate;
private LocalDateTime lastModifiedDate;
private boolean isDeleted;

public CommentReplyDTO() {
}

public CommentReplyDTO(String memberId, String content, LocalDateTime postedDate, LocalDateTime lastModifiedDate,
boolean isDeleted) {
this.memberId = memberId;
this.content = content;
this.postedDate = postedDate;
this.lastModifiedDate = lastModifiedDate;
this.isDeleted = isDeleted;
}

public String getMemberId() {
return memberId;
}

public void setMemberId(String memberId) {
this.memberId = memberId;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public LocalDateTime getPostedDate() {
return postedDate;
}

public void setPostedDate(LocalDateTime postedDate) {
this.postedDate = postedDate;
}

public LocalDateTime getLastModifiedDate() {
return lastModifiedDate;
}

public void setLastModifiedDate(LocalDateTime lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}

public boolean isDeleted() {
return isDeleted;
}

public void setDeleted(boolean deleted) {
isDeleted = deleted;
}

@Override
public String toString() {
return "CommentReplyDTO{" +
"memberId='" + memberId + '\'' +
", content='" + content + '\'' +
", postedDate=" + postedDate +
", lastModifiedDate=" + lastModifiedDate +
", isDeleted=" + isDeleted +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
import java.util.List;

import org.omoknoone.onionhotsayyo.comment.command.aggregate.Comment;
import org.omoknoone.onionhotsayyo.comment.command.dto.CommentReplyDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface CommentRepository extends JpaRepository<Comment, Integer> {

@Query("SELECT c FROM Comment c WHERE c.memberId = :memberId UNION SELECT r FROM Reply r WHERE r.memberId = :memberId")
List<CommentReplyDTO> findAllCommentsByMemberId(String memberId);

List<Comment> findAllByMemberId(String memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import java.util.List;

import org.omoknoone.onionhotsayyo.comment.command.aggregate.Comment;
import org.omoknoone.onionhotsayyo.comment.command.dto.CommentCreateDTO;
import org.omoknoone.onionhotsayyo.comment.command.dto.CommentDTO;
import org.omoknoone.onionhotsayyo.comment.command.dto.CommentReplyDTO;

public interface CommentService {
public void createComment(CommentDTO commentCreateDTO);
public void modifyComment(CommentDTO commentDetailDTO);
public void removeComment(int commentid);
void createComment(CommentDTO commentCreateDTO);
void modifyComment(CommentDTO commentDetailDTO);
void removeComment(int commentid);
List<CommentReplyDTO> viewCommentListByMe(String memberId);
}
Loading

0 comments on commit dee3de3

Please sign in to comment.