(@RequestBody CommentDto dto, Integer bno, HttpSession session)
| 49 | // } |
| 50 | // 댓글을 등록하는 메서드 |
| 51 | @PostMapping("/comments") // /ch4/comments?bno=1085 POST |
| 52 | public ResponseEntity<String> write(@RequestBody CommentDto dto, Integer bno, HttpSession session) { |
| 53 | // String commenter = (String)session.getAttribute("id"); |
| 54 | String commenter = "asdf"; |
| 55 | dto.setCommenter(commenter); |
| 56 | dto.setBno(bno); |
| 57 | System.out.println("dto = " + dto); |
| 58 | |
| 59 | try { |
| 60 | if(service.write(dto)!=1) |
| 61 | throw new Exception("Write failed."); |
| 62 | |
| 63 | return new ResponseEntity<>("WRT_OK", HttpStatus.OK); |
| 64 | } catch (Exception e) { |
| 65 | e.printStackTrace(); |
| 66 | return new ResponseEntity<String>("WRT_ERR", HttpStatus.BAD_REQUEST); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | // 지정된 댓글을 삭제하는 메서드 |
| 71 | @DeleteMapping("/comments/{cno}") // DELETE /comments/1?bno=1085 <-- 삭제할 댓글 번호 |
nothing calls this directly
no test coverage detected