Open
Conversation
wonjunYou
reviewed
Jan 3, 2024
Member
wonjunYou
left a comment
There was a problem hiding this comment.
전반적으로 깔끔하게 잘 짜셨습니다! 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 | |||
Member
There was a problem hiding this comment.
일반적으로 api에서 도메인을 복수형으로 사용할 것을 권장드립니다!!!
Comment on lines
+1
to
+49
| 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(); | ||
| } | ||
| } No newline at end of file |
Comment on lines
+40
to
+45
|
|
||
| public void update(String title, String body) { | ||
| this.title = title; | ||
| this.body = body; | ||
| } | ||
| } |
Comment on lines
+7
to
+11
| @Getter | ||
| public class BoardCreateRequest { | ||
| private Long member; | ||
| private String title; | ||
| private String body; |
Member
There was a problem hiding this comment.
제가 말씀드리진 않았지만, java 17을 사용하시니 record에 대해서 알아보시고 적용해 보는 것도 좋을 것 같아요!
Comment on lines
+54
to
+58
| @Transactional | ||
| public void delete(Long id) { | ||
| boardRepository.deleteById(id); | ||
| } | ||
| } No newline at end of file |
Comment on lines
+21
to
+29
| @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); | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
여기서 에러 대신에 널 체킹으로 빼는 이유는 무엇인가요>??
| spring: | ||
| datasource: | ||
| url: jdbc:mysql://localhost:3306/jpa?serverTimezone=UTC | ||
| url: ${DB_URL} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
api링크와 erd가 누락되어 다시 제출합니다! 죄송합니다.