| 69 | |
| 70 | // 지정된 댓글을 삭제하는 메서드 |
| 71 | @DeleteMapping("/comments/{cno}") // DELETE /comments/1?bno=1085 <-- 삭제할 댓글 번호 |
| 72 | public ResponseEntity<String> remove(@PathVariable Integer cno, Integer bno, HttpSession session) { |
| 73 | // String commenter = (String)session.getAttribute("id"); |
| 74 | String commenter = "asdf"; |
| 75 | |
| 76 | try { |
| 77 | int rowCnt = service.remove(cno, bno, commenter); |
| 78 | |
| 79 | if(rowCnt!=1) |
| 80 | throw new Exception("Delete Failed"); |
| 81 | |
| 82 | return new ResponseEntity<>("DEL_OK", HttpStatus.OK); |
| 83 | } catch (Exception e) { |
| 84 | e.printStackTrace(); |
| 85 | return new ResponseEntity<>("DEL_ERR", HttpStatus.BAD_REQUEST); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // 지정된 게시물의 모든 댓글을 가져오는 메서드 |
| 90 | @GetMapping("/comments") // /comments?bno=1080 GET |