-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from hook-killer/feat/28-reply
[FEATURE] reply 기능 구현 완료
- Loading branch information
Showing
15 changed files
with
291 additions
and
24 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/HookKiller/server/board/controller/ReplyController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package HookKiller.server.board.controller; | ||
|
||
import HookKiller.server.board.dto.ReplyResponseDto; | ||
import HookKiller.server.board.service.ReplyService; | ||
import HookKiller.server.common.type.LanguageType; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/reply") | ||
@RequiredArgsConstructor | ||
public class ReplyController { | ||
|
||
private final ReplyService replyService; | ||
|
||
@PostMapping | ||
public void createReply(@RequestBody ReplyResponseDto responseDto) { | ||
replyService.createReply(responseDto); | ||
} | ||
|
||
@GetMapping("/{articleId}") | ||
public List<ReplyResponseDto> getReplyList(@PathVariable Long articleId, HttpServletRequest request) { | ||
return replyService.getReplyList(articleId, LanguageType.findTypeByRequest(request)); | ||
} | ||
|
||
@DeleteMapping("/{replyId}") | ||
public ResponseEntity<String> deleteReply(@PathVariable Long replyId) { | ||
replyService.deleteReply(replyId); | ||
return ResponseEntity.ok("삭제처리가 완료되었습니다."); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/HookKiller/server/board/dto/ReplyResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package HookKiller.server.board.dto; | ||
|
||
|
||
import HookKiller.server.board.entity.Reply; | ||
import HookKiller.server.board.entity.ReplyContent; | ||
import HookKiller.server.common.AbstractTimeStamp; | ||
import HookKiller.server.common.type.LanguageType; | ||
import HookKiller.server.user.entity.User; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ReplyResponseDto extends AbstractTimeStamp { | ||
|
||
private Long articleId; | ||
|
||
private Long replyId; | ||
|
||
private LanguageType orgReplyLanguage; | ||
|
||
private User createUser; | ||
|
||
private String content; | ||
|
||
public static ReplyResponseDto of(Reply reply, ReplyContent replyContent) { | ||
return ReplyResponseDto.builder() | ||
.replyId(reply.getId()) | ||
.createUser(reply.getCreatedUser()) | ||
.content(replyContent.getContent()) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/HookKiller/server/board/exception/ReplyContentNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package HookKiller.server.board.exception; | ||
|
||
import HookKiller.server.common.exception.BaseException; | ||
|
||
public class ReplyContentNotFoundException extends BaseException { | ||
|
||
public static final BaseException EXCEPTION = new ReplyContentNotFoundException(); | ||
|
||
private ReplyContentNotFoundException() { | ||
super(BoardException.REPLY_CONTENT_NOT_FOUND_ERROR); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/HookKiller/server/board/repository/ReplyContentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package HookKiller.server.board.repository; | ||
|
||
import HookKiller.server.board.entity.Reply; | ||
import HookKiller.server.board.entity.ReplyContent; | ||
import HookKiller.server.common.type.LanguageType; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface ReplyContentRepository extends JpaRepository<ReplyContent, Long> { | ||
|
||
Optional<ReplyContent> findByReplyAndLanguage(Reply reply, LanguageType language); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/HookKiller/server/board/repository/ReplyRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package HookKiller.server.board.repository; | ||
|
||
import HookKiller.server.board.entity.Article; | ||
import HookKiller.server.board.entity.Reply; | ||
import HookKiller.server.board.type.ReplyStatus; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface ReplyRepository extends JpaRepository<Reply, Long> { | ||
List<Reply> findAllByArticleAndReplyStatus(Article article, ReplyStatus replyStatus); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.