@@ -82,56 +82,7 @@ public ResponseEntity<?> getPostList() {
82
82
return ResponseEntity .ok ().body (ResponseDto .success ("전체 게시글 조회 성공" , postList ));
83
83
}
84
84
85
- // 페이징 처리 + 검색 기능 : 은미
86
- // @GetMapping ("/posts/search")
87
- // public String searchPost (Model model,
88
- // @PageableDefault(page = 0, size = 10, sort = "id", direction = Sort.Direction.DESC) Pageable pageable,
89
- // String title) { // model : 데이터를 받아서 우리가 보는 페이지로 넘겨줄때 사용
90
- //
91
- // Page<Post> list = null;
92
- //
93
- // if (title == null) {
94
- // list = postService.searchPost(pageable);
95
- // } else {
96
- // list = postService.rightSearchPost(title, pageable);
97
- //
98
- // }
99
- //
100
- // int nowPage = list.getPageable().getPageNumber() +1;
101
- // int startPage = Math.max(nowPage -4, 1);
102
- // int endPage = Math.min(nowPage +5, list.getTotalPages());
103
- //
104
- // model.addAttribute("search", list);// search라는 이름으로 보낸다, 뒤에 있는 것을
105
- // model.addAttribute("nowPage",nowPage);
106
- // model.addAttribute("startPage", startPage);
107
- // model.addAttribute("endPage", endPage);
108
- //
109
- // return "searchPost";
110
- // }
111
-
112
-
113
- // // 성공함. 그러나 더 build up 해보기
114
- // @GetMapping("/posts/search")
115
- // public ResponseEntity<?> searchPost(
116
- //// @RequestParam(defaultValue = "0") int page,
117
- //// @RequestParam(defaultValue = "10") int size,
118
- // @RequestParam(required = false) String title) {
119
- //
120
- // int page = 0;
121
- // int size = 10;
122
- //
123
- // Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "id"));
124
- // Page<Post> postsPage;
125
- //
126
- // if (title == null || title.isEmpty()) {
127
- // postsPage = postService.searchPost(pageable);
128
- // } else {
129
- // postsPage = postService.rightSearchPost(title, pageable);
130
- // }
131
- //
132
- // return ResponseEntity.ok(postsPage);
133
- // }
134
-
85
+ // 검색
135
86
@ GetMapping ("/posts/search" )
136
87
public ResponseEntity <?> searchPost (
137
88
@ RequestParam (value = "title" , required = false ) String title ,
@@ -176,13 +127,17 @@ public ResponseEntity<?> searchPost (
176
127
return ResponseEntity .ok ().body (ResponseDto .success ("검색 성공" , responseBody ));
177
128
}
178
129
179
-
180
-
181
130
@ GetMapping ("/posts/category/{category}" )
182
131
public ResponseEntity <?> getPostByCategoryList (@ PathVariable String category ) {
183
132
List <GetPostListResponseDto > postList = postService .getPostByCategoryList (category );
184
133
return ResponseEntity .ok ().body (ResponseDto .success ("전체 게시글 조회 성공" , postList ));
185
134
}
186
135
136
+ // hit
137
+ @ GetMapping ("/posts/read/{id}" )
138
+ public String readHit (@ PathVariable Long id ) {
139
+ postService .updateHit (id ); // views++
140
+ return "success" ;
141
+ }
187
142
188
143
}
0 commit comments