Skip to content

Commit 1d19193

Browse files
author
bu2000
committed
change some problems
1 parent e47e259 commit 1d19193

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/main/java/com/webservice/algorithmchef/controller/BoardController.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public class BoardController {
2727
// 게시글 목록 조회(게시판)
2828
@GetMapping("/posts")
2929
public ResponseEntity<BoardPostListResponse> getPostList(
30-
@RequestParam(defaultValue = "0") int page,
31-
@RequestParam(defaultValue = "20") int size,
32-
@RequestParam(defaultValue = "createdAt,desc") String sort,
33-
@RequestParam(required = false) String filter
30+
@RequestParam(defaultValue = "0",value="page") int page,
31+
@RequestParam(defaultValue = "20",value="size") int size,
32+
@RequestParam(defaultValue = "createdAt,desc",value="sort") String sort,
33+
@RequestParam(required = false,value="filter") String filter
3434
) {
3535
BoardPostListResponse response = boardService.getPostList(page, size, sort, filter);
3636
return ResponseEntity.ok(response);
@@ -55,10 +55,10 @@ public ResponseEntity<Map<String, String>> createPost(
5555
// 게시글 조회
5656
@GetMapping("/post/{postId}")
5757
public ResponseEntity<BoardPostResponse> getPostDetail(
58-
@PathVariable Long postId,
59-
@RequestParam(defaultValue = "0") int page,
60-
@RequestParam(defaultValue = "20") int size,
61-
@RequestParam(defaultValue = "createdAt,asc") String sort
58+
@PathVariable("postId") Long postId,
59+
@RequestParam(defaultValue = "0",value="page") int page,
60+
@RequestParam(defaultValue = "20",value="size") int size,
61+
@RequestParam(defaultValue = "createdAt,asc",value="sort") String sort
6262
) {
6363
try {
6464
BoardPostResponse response = boardService.getPostDetail(postId, page, size, sort);
@@ -71,7 +71,7 @@ public ResponseEntity<BoardPostResponse> getPostDetail(
7171
// 댓글 작성
7272
@PostMapping("/post/{postId}/comment")
7373
public ResponseEntity<Map<String, String>> createComment(
74-
@PathVariable Long postId,
74+
@PathVariable("postId") Long postId,
7575
@RequestBody BoardCommentRequest requestDto,
7676
@AuthenticationPrincipal UserDetails userDetails
7777
) {
@@ -91,10 +91,10 @@ public ResponseEntity<Map<String, String>> createComment(
9191
// 대댓글 조회
9292
@GetMapping("/comments/{commentId}/replies")
9393
public ResponseEntity<CommentReplyListResponse> getReplies(
94-
@PathVariable Long commentId,
95-
@RequestParam(defaultValue = "0") int page,
96-
@RequestParam(defaultValue = "20") int size,
97-
@RequestParam(defaultValue = "createdAt,asc") String sort
94+
@PathVariable("commentId") Long commentId,
95+
@RequestParam(defaultValue = "0",value="page") int page,
96+
@RequestParam(defaultValue = "10",value="size") int size,
97+
@RequestParam(defaultValue = "createdAt,asc",value="sort") String sort
9898
) {
9999
try {
100100
CommentReplyListResponse response = boardService.getReplies(commentId, page, size, sort);
@@ -107,7 +107,7 @@ public ResponseEntity<CommentReplyListResponse> getReplies(
107107
// 게시글 수정
108108
@PutMapping("/post/{postId}")
109109
public ResponseEntity<Map<String, String>> updatePost(
110-
@PathVariable Long postId,
110+
@PathVariable("postId") Long postId,
111111
@RequestBody BoardPostRequest requestDto,
112112
@AuthenticationPrincipal UserDetails userDetails
113113
) {
@@ -133,7 +133,7 @@ public ResponseEntity<Map<String, String>> updatePost(
133133
// 게시글 삭제
134134
@DeleteMapping("/post/{postId}")
135135
public ResponseEntity<Map<String, String>> deletePost(
136-
@PathVariable Long postId,
136+
@PathVariable("postId") Long postId,
137137
@AuthenticationPrincipal UserDetails userDetails
138138
) {
139139
if (userDetails == null) {

src/main/java/com/webservice/algorithmchef/dto/board/BoardPostListResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ public static class BoardPostSimple {
2727
private String createdAt;
2828
private String category;
2929
private String content; // 목록 미리보기용
30+
private Long postId;
3031

3132
public static BoardPostSimple from(BoardPost post) {
3233
return BoardPostSimple.builder()
3334
.title(post.getTitle())
35+
.postId(post.getPostId())
3436
// User 엔티티의 userId (로그인 아이디) 사용
3537
.userId(post.getUser().getUserId())
3638
// 날짜 포맷팅 (yyyy-MM-dd)

0 commit comments

Comments
 (0)