-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[feat] 댓글 Paging기능 추가
- Loading branch information
Showing
13 changed files
with
428 additions
and
101 deletions.
There are no files selected for viewing
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
92 changes: 43 additions & 49 deletions
92
src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.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,89 +1,83 @@ | ||
package com.bbteam.budgetbuddies.domain.comment.controller; | ||
|
||
|
||
import com.bbteam.budgetbuddies.domain.comment.dto.CommentRequestDto; | ||
import com.bbteam.budgetbuddies.domain.comment.dto.CommentResponseDto; | ||
import com.bbteam.budgetbuddies.domain.comment.service.CommentService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.Parameters; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class CommentController { | ||
|
||
private final CommentService commentService; | ||
|
||
// user, discountInfo 인증 어노테이션 추후 추가 예정 | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
public interface CommentController { | ||
@Operation(summary = "[User] 특정 할인 정보 게시글에 댓글달기", description = "특정 할인 정보 게시글에 댓글을 다는 API입니다.") | ||
@ApiResponses({ | ||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), | ||
}) | ||
@Parameters({ | ||
@Parameter(name = "userId", description = "현재 댓글을 다는 유저 id입니다."), | ||
@Parameter(name = "discountInfoId", description = "댓글을 다는 할인 정보 게시글 id입니다."), | ||
@Parameter(name = "content", description = "댓글 내용입니다."), | ||
@Parameter(name = "userId", description = "현재 댓글을 다는 유저 id입니다. parameter"), | ||
@Parameter(name = "discountInfoId", description = "댓글을 다는 할인 정보 게시글 id입니다. requestBody"), | ||
@Parameter(name = "content", description = "댓글 내용입니다. requestBody"), | ||
}) | ||
@PostMapping("/discounts/comments/{userId}/add") | ||
public ResponseEntity<CommentResponseDto.DiscountInfoSuccessDto> saveDiscountInfoComment( | ||
@RequestParam("userId") Long userId, | ||
@RequestBody CommentRequestDto.DiscountInfoCommentDto discountInfoCommentDto){ | ||
CommentResponseDto.DiscountInfoSuccessDto dto = commentService.saveDiscountComment(userId, discountInfoCommentDto); | ||
return ResponseEntity.ok(dto); | ||
} | ||
ResponseEntity<CommentResponseDto.DiscountInfoSuccessDto> saveDiscountInfoComment( | ||
Long userId, | ||
CommentRequestDto.DiscountInfoCommentDto discountInfoCommentDto); | ||
|
||
|
||
@Operation(summary = "[User] 특정 할인 정보 게시글의 댓글 조회하기", description = "특정 할인 정보 게시글의 댓글을 가져오는 API입니다.") | ||
@ApiResponses({ | ||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), | ||
}) | ||
@Parameters({ | ||
@Parameter(name = "discountInfoId", description = "댓글을 가져올 할인 정보 게시글 id입니다."), | ||
@Parameter(name = "discountInfoId", description = "댓글을 가져올 할인 정보 게시글 id입니다. parameter"), | ||
@Parameter(name = "page", description = "페이징을 위한 페이지 번호입니다. 0부터 시작합니다. parameter"), | ||
@Parameter(name = "size", description = "페이징을 위한 페이지 사이즈입니다. default는 20입니다. parameter") | ||
}) | ||
@GetMapping("/discounts/comments/get/{discountInfoId}") | ||
public ResponseEntity<List<CommentResponseDto.DiscountInfoCommentDto>> findAllByDiscountInfo( | ||
@RequestParam("discountInfoId") Long discountInfoId){ | ||
List<CommentResponseDto.DiscountInfoCommentDto> result = commentService.findByDiscountInfo(discountInfoId); | ||
return ResponseEntity.ok(result); | ||
} | ||
ResponseEntity<Page<CommentResponseDto.DiscountInfoCommentDto>> findAllByDiscountInfo( | ||
Long discountInfoId, | ||
Pageable pageable); | ||
|
||
@Operation(summary = "[User] 특정 지원 정보 게시글에 댓글달기", description = "특정 지원 정보 게시글에 댓글을 다는 API입니다.") | ||
@ApiResponses({ | ||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), | ||
}) | ||
@Parameters({ | ||
@Parameter(name = "userId", description = "현재 댓글을 다는 유저 id입니다."), | ||
@Parameter(name = "supportInfoId", description = "댓글을 다는 지원 정보 게시글 id입니다."), | ||
@Parameter(name = "content", description = "댓글 내용입니다."), | ||
@Parameter(name = "userId", description = "현재 댓글을 다는 유저 id입니다. parameter"), | ||
@Parameter(name = "supportInfoId", description = "댓글을 다는 지원 정보 게시글 id입니다. requestBody"), | ||
@Parameter(name = "content", description = "댓글 내용입니다. requestBody"), | ||
}) | ||
@PostMapping("/supports/comments/{userId}/add") | ||
public ResponseEntity<CommentResponseDto.SupportInfoSuccessDto> saveSupportInfoComment( | ||
@RequestParam("userId") Long userId, | ||
@RequestBody CommentRequestDto.SupportInfoCommentDto supportInfoCommentDto){ | ||
CommentResponseDto.SupportInfoSuccessDto dto = commentService.saveSupportComment(userId, supportInfoCommentDto); | ||
return ResponseEntity.ok(dto); | ||
} | ||
ResponseEntity<CommentResponseDto.SupportInfoSuccessDto> saveSupportInfoComment( | ||
Long userId, | ||
CommentRequestDto.SupportInfoCommentDto supportInfoCommentDto); | ||
|
||
@Operation(summary = "[User] 특정 지원 정보 게시글의 댓글 조회하기", description = "특정 지원 정보 게시글의 댓글을 가져오는 API입니다.") | ||
@ApiResponses({ | ||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), | ||
}) | ||
@Parameters({ | ||
@Parameter(name = "supportInfoId", description = "댓글을 가져올 지원 정보 게시글 id입니다."), | ||
}) | ||
@GetMapping("/supports/comments/get/{supportInfoId}") | ||
public ResponseEntity<List<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportInfo( | ||
@RequestParam("supportInfoId") Long supportInfoId){ | ||
List<CommentResponseDto.SupportInfoCommentDto> result = commentService.findBySupportInfo(supportInfoId); | ||
return ResponseEntity.ok(result); | ||
} | ||
|
||
@Parameter(name = "supportInfoId", description = "댓글을 가져올 지원 정보 게시글 id입니다. parameter"), | ||
@Parameter(name = "page", description = "페이징을 위한 페이지 번호입니다. 0부터 시작합니다. parameter"), | ||
@Parameter(name = "size", description = "페이징을 위한 페이지 사이즈입니다. default는 20입니다. parameter") | ||
|
||
|
||
}) | ||
ResponseEntity<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportInfo( | ||
Long supportInfoId, | ||
Pageable pageable); | ||
|
||
@Operation(summary = "[User] 특정 댓글 삭제하기", description = "특정 댓글을 삭제하는 API입니다.") | ||
@ApiResponses({ | ||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), | ||
}) | ||
@Parameters({ | ||
@Parameter(name = "commentId", description = "삭제할 댓글 id 입니다. parameter") | ||
}) | ||
@GetMapping("/comments/delete") | ||
ResponseEntity<String> deleteComment(Long commentId); | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerImpl.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,60 @@ | ||
package com.bbteam.budgetbuddies.domain.comment.controller; | ||
|
||
import com.bbteam.budgetbuddies.domain.comment.dto.CommentRequestDto; | ||
import com.bbteam.budgetbuddies.domain.comment.dto.CommentResponseDto; | ||
import com.bbteam.budgetbuddies.domain.comment.service.CommentService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class CommentControllerImpl implements CommentController{ | ||
|
||
private final CommentService commentService; | ||
|
||
@PostMapping("/discounts/comments") | ||
public ResponseEntity<CommentResponseDto.DiscountInfoSuccessDto> saveDiscountInfoComment( | ||
@RequestParam("userId") Long userId, | ||
@RequestBody CommentRequestDto.DiscountInfoCommentDto discountInfoCommentDto){ | ||
CommentResponseDto.DiscountInfoSuccessDto dto = commentService.saveDiscountComment(userId, discountInfoCommentDto); | ||
return ResponseEntity.ok(dto); | ||
} | ||
|
||
|
||
@GetMapping("/discounts/comments") | ||
public ResponseEntity<Page<CommentResponseDto.DiscountInfoCommentDto>> findAllByDiscountInfo( | ||
@RequestParam("discountInfoId") Long discountInfoId, | ||
@PageableDefault(size = 20, page = 0) Pageable pageable){ | ||
Page<CommentResponseDto.DiscountInfoCommentDto> result = commentService.findByDiscountInfoWithPaging(discountInfoId, pageable); | ||
return ResponseEntity.ok(result); | ||
} | ||
|
||
|
||
@PostMapping("/supports/comments") | ||
public ResponseEntity<CommentResponseDto.SupportInfoSuccessDto> saveSupportInfoComment( | ||
@RequestParam("userId") Long userId, | ||
@RequestBody CommentRequestDto.SupportInfoCommentDto supportInfoCommentDto){ | ||
CommentResponseDto.SupportInfoSuccessDto dto = commentService.saveSupportComment(userId, supportInfoCommentDto); | ||
return ResponseEntity.ok(dto); | ||
} | ||
|
||
|
||
@GetMapping("/supports/comments") | ||
public ResponseEntity<Page<CommentResponseDto.SupportInfoCommentDto>> findAllBySupportInfo( | ||
@RequestParam("supportInfoId") Long supportInfoId, | ||
@PageableDefault(size = 20, page = 0)Pageable pageable){ | ||
Page<CommentResponseDto.SupportInfoCommentDto> result = commentService.findBySupportInfoWithPaging(supportInfoId, pageable); | ||
return ResponseEntity.ok(result); | ||
} | ||
|
||
|
||
public ResponseEntity<String> deleteComment(@RequestParam("commentId") Long commentId) { | ||
commentService.deleteComment(commentId); | ||
return ResponseEntity.ok("ok"); | ||
} | ||
|
||
} |
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
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.