Skip to content

Commit

Permalink
fix: 댓글 생성, 조회 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jihyo-j committed Mar 6, 2024
1 parent 075f966 commit 082c83b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import core.kobaco.application.comment.service.CommentLikeDetailResponse;
import core.kobaco.application.comment.service.CommentService;
import core.kobaco.application.comment.service.dto.CommentCreateResponse;
import core.kobaco.application.comment.service.dto.CommentCreateRequest;
import core.kobaco.application.comment.service.dto.CommentDetailResponse;
import core.kobaco.global.ApiResponse;

Expand All @@ -21,8 +21,8 @@ public class CommentController {
private final CommentService commentService;
@Operation(summary = "댓글 생성")
@PostMapping("/{advertiseId}")
public ResponseEntity<CommentCreateResponse> createComment(@RequestBody CommentCreateResponse commentDTO, @PathVariable Long advertiseId) {
CommentCreateResponse createdComment = commentService.createComment(commentDTO.getContent(), advertiseId);
public ResponseEntity<CommentCreateRequest> createComment(@RequestBody CommentCreateRequest commentDTO, @PathVariable Long advertiseId) {
CommentCreateRequest createdComment = commentService.createComment(commentDTO.getContent(), advertiseId);
return ResponseEntity.status(HttpStatus.CREATED).body(createdComment);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package core.kobaco.application.comment.service;

import core.kobaco.application.comment.service.dto.CommentCreateResponse;
import core.kobaco.application.comment.service.dto.CommentCreateRequest;
import core.kobaco.application.comment.service.dto.CommentDetailResponse;
import core.kobaco.domain.comment.*;

Expand Down Expand Up @@ -31,14 +31,14 @@ public CommentService(CommentRepository commentRepository, UserReader userReader
}

@Transactional
public CommentCreateResponse createComment(String content, Long advertiseId) {
public CommentCreateRequest createComment(String content, Long advertiseId) {
final Long userId = userUtils.getRequestUserId();
if (userId == null) {
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "사용자가 인증되지 않았습니다.");
}
Comment comment = new Comment(null, content, userId);
Comment savedCommentEntity = commentRepository.save(comment, advertiseId);
return CommentCreateResponse.of(savedCommentEntity.getContent());
return CommentCreateRequest.of(savedCommentEntity.getContent());
}

public List<CommentDetailResponse> getAllComments(Long advertiseId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

@Getter
@NoArgsConstructor
public class CommentCreateResponse {
public class CommentCreateRequest {
private String content;

public CommentCreateResponse(String content) {
public CommentCreateRequest(String content) {
this.content = content;
}

public static CommentCreateResponse of(String content) {
return new CommentCreateResponse(content);
public static CommentCreateRequest of(String content) {
return new CommentCreateRequest(content);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;


@Getter
@NoArgsConstructor
public class CommentDetailResponse {
Expand Down

0 comments on commit 082c83b

Please sign in to comment.