-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[14주차] 홍정우 학습 PR 제출입니다. #6
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전반적으로 깔끔하게 잘 짜셨습니다! n+1 문제에 대한 해결책, 페이징, 에러에 관한 핸들러 등등 기본적인 crud api를 기반으로 계속 확장해 나가시면 좋을 것 같아요 !! 고생 많으셨습니다 :) 앞으로 프로젝트도 기대하겠습니다 ~~
@@ -0,0 +1,3 @@ | |||
<img width="769" alt="스크린샷 2024-01-03 오후 4 01 30" src="https://github.com/Erichong7/jpa-practice/assets/97429550/5cfd774e-2d59-419e-92e1-647043f22e1c"> | |||
|
|||
api 문서 : https://documenter.getpostman.com/view/29836884/2s9YsFEEBq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
일반적으로 api에서 도메인을 복수형으로 사용할 것을 권장드립니다!!!
package com.example.jpa.board.controller; | ||
|
||
import com.example.jpa.board.dto.request.BoardCreateRequest; | ||
import com.example.jpa.board.dto.request.BoardUpdateRequest; | ||
import com.example.jpa.board.dto.response.BoardResponse; | ||
import com.example.jpa.board.service.BoardService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("api/board") | ||
@RequiredArgsConstructor | ||
public class BoardController { | ||
|
||
private final BoardService boardService; | ||
|
||
@PostMapping | ||
public ResponseEntity<Void> create(@RequestBody BoardCreateRequest boardCreateRequest) { | ||
|
||
boardService.create(boardCreateRequest); | ||
|
||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@GetMapping("/{id}") | ||
public ResponseEntity<BoardResponse> findOne(@PathVariable("id") Long id) { | ||
|
||
BoardResponse boardResponse = boardService.findOne(id); | ||
|
||
return ResponseEntity.ok(boardResponse); | ||
} | ||
|
||
@PatchMapping("/{id}") | ||
public ResponseEntity<Void> update(@PathVariable("id") Long id, @RequestBody BoardUpdateRequest boardUpdateRequest) { | ||
|
||
boardService.update(id, boardUpdateRequest); | ||
|
||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
public ResponseEntity<Void> delete(@PathVariable("id") Long id) { | ||
|
||
boardService.delete(id); | ||
|
||
return ResponseEntity.ok().build(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
게시글 전체 조회 api가 없는 것 같아요 !! ㅠ
|
||
public void update(String title, String body) { | ||
this.title = title; | ||
this.body = body; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변경 감지 굿입니다
@Getter | ||
public class BoardCreateRequest { | ||
private Long member; | ||
private String title; | ||
private String body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 말씀드리진 않았지만, java 17을 사용하시니 record에 대해서 알아보시고 적용해 보는 것도 좋을 것 같아요!
@Transactional | ||
public void delete(Long id) { | ||
boardRepository.deleteById(id); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
삭제에 대한 예외처리도 필요할 것 같아요 !
@PostMapping("/create") | ||
public ResponseEntity<Void> create(@RequestBody CommentCreateRequest commentCreateRequest) { | ||
Long saveResult = commentService.create(commentCreateRequest); | ||
if (saveResult != null) { | ||
return new ResponseEntity<>(HttpStatus.OK); | ||
} else { | ||
return new ResponseEntity<>(HttpStatus.NOT_FOUND); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 에러 대신에 널 체킹으로 빼는 이유는 무엇인가요>??
@@ -3,10 +3,10 @@ server: | |||
|
|||
spring: | |||
datasource: | |||
url: jdbc:mysql://localhost:3306/jpa?serverTimezone=UTC | |||
url: ${DB_URL} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오 좋습니다!
api링크와 erd가 누락되어 다시 제출합니다! 죄송합니다.