티스토리 뷰
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
//글의 상세 내역 보는 컨트롤러
@GetMapping(value="/select")
public ResponseEntity<?> selectOne(@RequestParam String userId){
log.info("!!!!!!!!!!!!!!!!!!!!!!!!boardDTO.getUserId() {} ", userId);
try {
if(userId != null) {
List<BoardEntity> entitiyList = boardService.selectBoard(userId);
log.info("111111111111111111111111111111111111111111111");
List<BoardDTO> dtos = entitiyList.stream().map(BoardDTO::new).collect(Collectors.toList());
log.info("2222222222222222222222222222222222222222222222222");
ResponseDTO response = ResponseDTO.builder().data(dtos).build();
log.info("333333333333333333333333333333333333333333");
return ResponseEntity.ok().body(response);
}else {
String msg = "게시글이 존재하지 않습니다.";
ResponseDTO response = ResponseDTO.builder().error(msg).build();
return ResponseEntity.badRequest().body(response);
}
}catch(Exception e){
String msg = e.getMessage();
ResponseDTO response = ResponseDTO.builder().error(msg).build();
return ResponseEntity.badRequest().body(response);
}
}
|
cs |
오류 발생해서 if 절 삭제함
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
//글의 상세 내역 보는 컨트롤러
@GetMapping(value="/select")
public ResponseEntity<?> selectOne(@RequestParam String userId){
log.info("!!!!!!!!!!!!!!!!!!!!!!!!boardDTO.getUserId() {} ", userId);
try {
List<BoardEntity> entitiyList = boardService.selectBoard(userId);
log.info("111111111111111111111111111111111111111111111");
List<BoardDTO> dtos = entitiyList.stream().map(BoardDTO::new).collect(Collectors.toList());
log.info("2222222222222222222222222222222222222222222222222");
ResponseDTO response = ResponseDTO.builder().data(dtos).build();
log.info("333333333333333333333333333333333333333333");
return ResponseEntity.ok().body(response);
}catch(Exception e){
String msg = e.getMessage();
ResponseDTO response = ResponseDTO.builder().error(msg).build();
return ResponseEntity.badRequest().body(response);
}
}
|
cs |
오류 발생없이 잘됨