Skip to content

Commit

Permalink
hotfix: 답글 생성 및 삭제 시에 인증 정보 포함하지 않도록 수정
Browse files Browse the repository at this point in the history
- 프론트에서 원활한 테스트를 위해 임시 적용 (#dev)
  • Loading branch information
kdkdhoho committed Feb 8, 2024
1 parent 03a0e7d commit 8db9892
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public record ReplyDeleteCommand(
Long listId,
Long commentId,
Long replyId,
String accessToken
Long replyId
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public class ReplyService {
private final ReplyRepository replyRepository;
private final CommentRepository commentRepository;

public ReplyCreateResponse createReply(Long listId, Long commentId, String accessToken, String content) {
public ReplyCreateResponse createReply(Long listId, Long commentId, String content) {
listRepository.getById(listId);
Long writerId = jwtManager.read(accessToken);
User user = userRepository.getById(writerId);
Comment comment = commentRepository.getReferenceById(commentId);
// Long writerId = jwtManager.read(accessToken); 개발 안정화까지 임의 주석 처리
User user = userRepository.getById(3L);
Comment comment = commentRepository.getById(commentId);

Reply reply = new Reply(comment, user, new Content(content));
Reply saved = replyRepository.save(reply);
Expand All @@ -39,8 +39,8 @@ public ReplyCreateResponse createReply(Long listId, Long commentId, String acces
}

public void delete(ReplyDeleteCommand command) {
Long writerId = jwtManager.read(command.accessToken());
userRepository.getById(writerId);
// Long writerId = jwtManager.read(command.accessToken()); 개발 안정화까지 임의 주석 처리
// userRepository.getById(writerId);
listRepository.getById(command.listId());
Comment comment = commentRepository.getById(command.commentId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -27,21 +26,21 @@ public class ReplyController {
ResponseEntity<ReplyCreateResponse> create(
@PathVariable(value = "listId") Long listId,
@PathVariable(value = "commentId") Long commentId,
@RequestHeader(value = "Authorization", defaultValue = "") String accessToken,
// @RequestHeader(value = "Authorization", defaultValue = "") String accessToken,
@RequestBody ReplyCreateRequest request
) {
ReplyCreateResponse response = replyService.createReply(listId, commentId, accessToken, request.content());
ReplyCreateResponse response = replyService.createReply(listId, commentId, request.content());
return ResponseEntity.status(CREATED).body(response);
}

@DeleteMapping("/{replyId}")
ResponseEntity<Void> deleteReply(
@PathVariable(value = "listId") Long listId,
@PathVariable(value = "commentId") Long commentId,
@PathVariable(value = "replyId") Long replyId,
@RequestHeader(value = "Authorization", defaultValue = "") String accessToken
@PathVariable(value = "replyId") Long replyId
// @RequestHeader(value = "Authorization", defaultValue = "") String accessToken
) {
ReplyDeleteCommand replyDeleteCommand = new ReplyDeleteCommand(listId, commentId, replyId, accessToken);
ReplyDeleteCommand replyDeleteCommand = new ReplyDeleteCommand(listId, commentId, replyId);
replyService.delete(replyDeleteCommand);
return ResponseEntity.noContent().build();
}
Expand Down

0 comments on commit 8db9892

Please sign in to comment.