Skip to content

Commit

Permalink
Merge pull request #75 from BudgetBuddiesTeam/refactor/#69
Browse files Browse the repository at this point in the history
[refactor] CommentAPI 수정
  • Loading branch information
wnd01jun authored Aug 4, 2024
2 parents 20b8f84 + 3b285a3 commit 237e5d2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public ResponseEntity<CommentResponseDto.DiscountInfoCommentDto> saveDiscountInf
}


@GetMapping("/discounts/comments")
@GetMapping("/discounts/{discountInfoId}/comments")
public ResponseEntity<Page<CommentResponseDto.DiscountInfoCommentDto>> findAllByDiscountInfo(
@RequestParam("discountInfoId") Long discountInfoId,
@PathVariable("discountInfoId") Long discountInfoId,
@PageableDefault(size = 20, page = 0) Pageable pageable){
Page<CommentResponseDto.DiscountInfoCommentDto> result = discountCommentService.findByInfoWithPaging(discountInfoId, pageable);
return ResponseEntity.ok(result);
Expand All @@ -56,22 +56,22 @@ public ResponseEntity<CommentResponseDto.SupportInfoCommentDto> saveSupportInfoC
}


@GetMapping("/supports/comments")
@GetMapping("/supports/{supportInfoId}/comments")
public ResponseEntity<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportInfo(
@RequestParam("supportInfoId") Long supportInfoId,
@PathVariable("supportInfoId") Long supportInfoId,
@PageableDefault(size = 20, page = 0)Pageable pageable){
Page<CommentResponseDto.SupportInfoCommentDto> result = supportCommentService.findByInfoWithPaging(supportInfoId, pageable);
return ResponseEntity.ok(result);
}

@PostMapping("/comments/delete")
public ResponseEntity<String> deleteComment(@RequestParam("commentId") Long commentId) {
@PostMapping("/comments/delete/{commentId}")
public ResponseEntity<String> deleteComment(@PathVariable("commentId") Long commentId) {
discountCommentService.deleteComment(commentId);
return ResponseEntity.ok("ok");
}

@GetMapping("/supports/comments/modify")
public ResponseEntity<CommentResponseDto.SupportInfoCommentDto> findSupportOne(@RequestParam("commentId")Long commentId) {
@GetMapping("/supports/comments/getOne/{commentId}")
public ResponseEntity<CommentResponseDto.SupportInfoCommentDto> findSupportOne(@PathVariable("commentId")Long commentId) {
CommentResponseDto.SupportInfoCommentDto result = supportCommentService.findCommentOne(commentId);
return ResponseEntity.ok(result);
}
Expand All @@ -83,8 +83,8 @@ public ResponseEntity<CommentResponseDto.SupportInfoCommentDto> modifySupportOne
return ResponseEntity.ok(result);
}

@GetMapping("/discounts/comments/modify")
public ResponseEntity<CommentResponseDto.DiscountInfoCommentDto> findDiscountOne(@RequestParam("commentId")Long commentId) {
@GetMapping("/discounts/comments/getOne/{commentId}")
public ResponseEntity<CommentResponseDto.DiscountInfoCommentDto> findDiscountOne(@PathVariable("commentId")Long commentId) {
CommentResponseDto.DiscountInfoCommentDto result = discountCommentService.findCommentOne(commentId);
return ResponseEntity.ok(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

Expand All @@ -35,7 +33,7 @@ ResponseEntity<CommentResponseDto.DiscountInfoCommentDto> saveDiscountInfoCommen
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"),
})
@Parameters({
@Parameter(name = "discountInfoId", description = "댓글을 가져올 할인 정보 게시글 id입니다. parameter"),
@Parameter(name = "discountInfoId", description = "댓글을 가져올 할인 정보 게시글 id입니다. pathVariable"),
@Parameter(name = "page", description = "페이징을 위한 페이지 번호입니다. 0부터 시작합니다. parameter"),
@Parameter(name = "size", description = "페이징을 위한 페이지 사이즈입니다. default는 20입니다. parameter")
})
Expand All @@ -61,7 +59,7 @@ ResponseEntity<CommentResponseDto.SupportInfoCommentDto> saveSupportInfoComment(
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"),
})
@Parameters({
@Parameter(name = "supportInfoId", description = "댓글을 가져올 지원 정보 게시글 id입니다. parameter"),
@Parameter(name = "supportInfoId", description = "댓글을 가져올 지원 정보 게시글 id입니다. pathVariable"),
@Parameter(name = "page", description = "페이징을 위한 페이지 번호입니다. 0부터 시작합니다. parameter"),
@Parameter(name = "size", description = "페이징을 위한 페이지 사이즈입니다. default는 20입니다. parameter")

Expand All @@ -76,7 +74,7 @@ ResponseEntity<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportI
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"),
})
@Parameters({
@Parameter(name = "commentId", description = "삭제할 댓글 id 입니다. parameter")
@Parameter(name = "commentId", description = "삭제할 댓글 id 입니다. pathVariable")
})
ResponseEntity<String> deleteComment(Long commentId);

Expand All @@ -85,17 +83,17 @@ ResponseEntity<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportI
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"),
})
@Parameters({
@Parameter(name = "commentId", description = "조회할 댓글 id 입니다. parameter")
@Parameter(name = "commentId", description = "조회할 댓글 id 입니다. pathVariable")
})
ResponseEntity<CommentResponseDto.SupportInfoCommentDto> findSupportOne(@RequestParam("commentId")Long commentId);

@Operation(summary = "[User] SupprotInfo의 댓글 변경 API", description = "특정 댓글을 변경하는 API입니다.")
@Operation(summary = "[User] SupportInfo의 댓글 변경 API", description = "특정 댓글을 변경하는 API입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"),
})
@Parameters({
@Parameter(name = "commentId", description = "변경할 댓글 id 입니다. requestbody"),
@Parameter(name = "comment", description = "변경할 댓글 내용입니다.. requestbody")
@Parameter(name = "content", description = "변경할 댓글 내용입니다.. requestbody")

})
ResponseEntity<CommentResponseDto.SupportInfoCommentDto> modifySupportOne(
Expand All @@ -107,7 +105,7 @@ ResponseEntity<CommentResponseDto.SupportInfoCommentDto> modifySupportOne(
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"),
})
@Parameters({
@Parameter(name = "commentId", description = "조회할 댓글 id 입니다. parameter")
@Parameter(name = "commentId", description = "조회할 댓글 id 입니다. pathVariable")
})
ResponseEntity<CommentResponseDto.DiscountInfoCommentDto> findDiscountOne(@RequestParam("commentId")Long commentId);

Expand All @@ -117,7 +115,7 @@ ResponseEntity<CommentResponseDto.SupportInfoCommentDto> modifySupportOne(
})
@Parameters({
@Parameter(name = "commentId", description = "변경할 댓글 id 입니다. requestbody"),
@Parameter(name = "comment", description = "변경할 댓글 내용입니다.. requestbody")
@Parameter(name = "content", description = "변경할 댓글 내용입니다.. requestbody")

})
ResponseEntity<CommentResponseDto.DiscountInfoCommentDto> modifyDiscountOne(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bbteam.budgetbuddies.domain.comment.dto;


import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Builder;
import lombok.Getter;

Expand All @@ -17,6 +18,7 @@ public static class DiscountInfoCommentDto{
private Long discountInfoId;
private String content;
private Integer anonymousNumber;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul")
private LocalDateTime createdAt;
}

Expand All @@ -28,6 +30,7 @@ public static class SupportInfoCommentDto{
private Long supportInfoId;
private String content;
private Integer anonymousNumber;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul")
private LocalDateTime createdAt;
}

Expand Down

0 comments on commit 237e5d2

Please sign in to comment.