Skip to content

[14주차] 홍정우 학습 PR 제출입니다.#6

Open
Erichong7 wants to merge 3 commits intoCOW-edu:mainfrom
Erichong7:main
Open

[14주차] 홍정우 학습 PR 제출입니다.#6
Erichong7 wants to merge 3 commits intoCOW-edu:mainfrom
Erichong7:main

Conversation

@Erichong7
Copy link
Copy Markdown

api링크와 erd가 누락되어 다시 제출합니다! 죄송합니다.

Copy link
Copy Markdown
Member

@wonjunYou wonjunYou left a 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일반적으로 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

게시글 전체 조회 api가 없는 것 같아요 !! ㅠ

Comment on lines +40 to +45

public void update(String title, String body) {
this.title = title;
this.body = body;
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경 감지 굿입니다

Comment on lines +7 to +11
@Getter
public class BoardCreateRequest {
private Long member;
private String title;
private String body;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 말씀드리진 않았지만, java 17을 사용하시니 record에 대해서 알아보시고 적용해 보는 것도 좋을 것 같아요!

Comment on lines +54 to +58
@Transactional
public void delete(Long id) {
boardRepository.deleteById(id);
}
} No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

삭제에 대한 예외처리도 필요할 것 같아요 !

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);
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 에러 대신에 널 체킹으로 빼는 이유는 무엇인가요>??

spring:
datasource:
url: jdbc:mysql://localhost:3306/jpa?serverTimezone=UTC
url: ${DB_URL}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오 좋습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants