Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/main/java/com/example/prdoit/controller/CommentController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.example.prdoit.controller;

import com.example.prdoit.dto.comment.*;
import com.example.prdoit.service.comment.CommentService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/comments")
public class CommentController {

private final CommentService commentService;

// 1. 댓글 조회
@GetMapping("/{contentId}")
public ResponseEntity<List<CommentResponseDto>> getComments(@PathVariable String contentId) {
return ResponseEntity.ok(commentService.getCommentList(contentId));
}

// 2. 댓글 작성
@PostMapping
public ResponseEntity<String> createComment(@RequestBody CommentRequestDto commentRequestDto) {
commentService.postComment(commentRequestDto);
return ResponseEntity.ok("댓글이 성공적으로 작성되었습니다!");
}

// 3. 대댓글 작성
@PostMapping("/reply")
public ResponseEntity<String> createReply(@RequestBody CommentReplyRequestDto commentReplyRequestDto) {
commentService.postCommentReply(commentReplyRequestDto);
return ResponseEntity.ok("대댓글이 성공적으로 작성되었습니다!");
}

// 4. 댓글 수정
@PatchMapping
public ResponseEntity<String> updateComment(@RequestBody CommentPatchDto commentPatchDto) {
commentService.patchComment(commentPatchDto);
return ResponseEntity.ok("댓글이 성공적으로 수정되었습니다!");
}

// 5.대댓글 수정
@PatchMapping("/reply")
public ResponseEntity<String> updateReply(@RequestBody CommentReplyPatchDto commentReplyPatchDto) {
commentService.patchCommentReply(commentReplyPatchDto);
return ResponseEntity.ok("대댓글이 성공적으로 수정되었습니다!");
}
}
15 changes: 0 additions & 15 deletions src/main/java/com/example/prdoit/controller/ProjectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,4 @@ public ResponseEntity<Object> deleteProject(@PathVariable String projectId) {
return ResponseEntity.badRequest().body("프로젝트 삭제에 실패했습니다.");
}
}

/*
@PutMapping("/product")
public ResponseEntity<Object> putBacklog(@RequestBody BacklogPutDto backlogPutDto) {
log.info("[putBacklog] 백로그 이동 요청");
try{
projectService.putBacklog(backlogPutDto);
return ResponseEntity.ok("백로그 이동에 성공했습니다.");
} catch (RuntimeException e){
log.error("[putBacklog] {}", e.getMessage());
return ResponseEntity.badRequest().body("백로그 이동에 실패했습니다.");
}
}

*/
}
14 changes: 14 additions & 0 deletions src/main/java/com/example/prdoit/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.prdoit.dto.user.LoginDto;
import com.example.prdoit.dto.user.UserDto;
import com.example.prdoit.exception.CustomException;
import com.example.prdoit.service.notification.NotificationService;
import com.example.prdoit.service.user.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -20,6 +21,7 @@
public class UserController {

private final UserService userService;
private final NotificationService notificationService;

@PostMapping("/signup")
public ResponseEntity<Object> signUp(@RequestBody UserDto userDto) {
Expand Down Expand Up @@ -141,4 +143,16 @@ public ResponseEntity<Object> checkPassword(@RequestBody LoginDto loginDto) {
}
}

@GetMapping("/notification/{userId}")
public ResponseEntity<Object> getNotificationList(@PathVariable String userId) {
log.info("[getNotificationList] 알림 목록 조회 시작 - User ID: {}", userId);

try {
return ResponseEntity.ok(notificationService.getNotificationList(userId));
} catch (CustomException e) {
log.error("[getNotificationList] 알림 목록 조회 실패 - 이유: {}", e.getMessage());
return ResponseEntity.badRequest().body(e.getMessage());
}
}

}
17 changes: 17 additions & 0 deletions src/main/java/com/example/prdoit/dto/comment/CommentPatchDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.prdoit.dto.comment;

import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CommentPatchDto {

private int commentId; // 수정할 댓글 ID
private String commentContent; // 수정된 댓글 내용
private LocalDateTime commentDate; // 수정된 날짜
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.prdoit.dto.comment;

import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CommentReplyPatchDto {

private int commentReplyId; // 수정할 대댓글 ID
private String commentReplyContent; // 수정된 대댓글 내용
private LocalDateTime commentReplyDate; // 수정된 날짜
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.prdoit.dto.comment;

import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CommentReplyRequestDto {

private int commentId; // 대댓글이 달릴 원본 댓글 ID
private String commentReplyContent; // 대댓글 내용
private String commentReplyNickname; // 대댓글 작성자 닉네임
private LocalDateTime commentReplyDate; // 대댓글 작성 날짜
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.prdoit.dto.comment;

import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CommentReplyResponseDto {

private int commentReplyId; // 대댓글 ID
private String commentReplyContent; // 대댓글 내용
private String commentReplyNickname; // 작성자 닉네임
private LocalDateTime commentReplyDate; // 대댓글 작성 날짜
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.prdoit.dto.comment;

import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CommentRequestDto {

private String contentId; // 댓글 달릴 게시글 ID
private String commentContent; // 댓글 내용
private String commentNickname; // 댓글 작성자 닉네임
private LocalDateTime commentDate; // 댓글 작성 날짜
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.prdoit.dto.comment;

import lombok.*;

import java.time.LocalDateTime;
import java.util.List;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CommentResponseDto {

private int commentId; // 댓글 ID
private String commentContent; // 댓글 내용
private String commentNickname; // 작성자 닉네임
private LocalDateTime commentDate; // 댓글 작성 날짜
private List<CommentReplyResponseDto> commentReplyResponseDtoList; // 대댓글 리스트
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.prdoit.dto.notification;

import lombok.*;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class NotificationResponseDto {
private int notificationId;
private String notificationContent;
private String contentId;
private String userId;
private int isRead;
}
8 changes: 4 additions & 4 deletions src/main/java/com/example/prdoit/model/IdTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public class IdTable {
@JsonIgnore
private List<SurveyTable> surveyTable;

@OneToMany(mappedBy = "id", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.EAGER)
@JsonIgnore
private List<ReadTable> readTable;

@OneToMany(mappedBy = "id", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.EAGER)
@JsonIgnore
private List<CommunityTable> communityTable;
Expand All @@ -47,4 +43,8 @@ public class IdTable {
@JsonIgnore
private List<ContentTable> contentTable;

@OneToMany(mappedBy = "userId", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.EAGER)
@JsonIgnore
private List<NotificationTable> notificationTable;

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ReadTable {
public class NotificationTable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int readId;
private int notificationId;

private int readContentId;
private String notificationContent;

private String contentId;

private int isRead;

@ManyToOne
@JoinColumn(name = "id")
private IdTable id;
@JoinColumn(name = "userId")
private IdTable userId;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.prdoit.repository;

import com.example.prdoit.model.NotificationTable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface NotificationTableRepository extends JpaRepository<NotificationTable, Integer> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.prdoit.service.comment;

import com.example.prdoit.dto.comment.*;

import java.util.List;

public interface CommentService {

List<CommentResponseDto> getCommentList(String contentId);

void postComment(CommentRequestDto commentRequestDto);

void postCommentReply(CommentReplyRequestDto commentReplyRequestDto);

void patchComment(CommentPatchDto commentPatchDto);

void patchCommentReply(CommentReplyPatchDto commentReplyPatchDto);
}
Loading