Skip to content
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

[5기 김강훈, 이수진] Spring Boot JPA 게시판 구현 미션 제출합니다. #279

Open
wants to merge 11 commits into
base: 수진,강훈-mission
Choose a base branch
from

Conversation

ssssujini99
Copy link
Member

📌 과제 설명

👩‍💻 요구 사항과 구현 내용

✅ 피드백 반영사항

✅ PR 포인트 & 궁금한 점

ssssujini99 and others added 11 commits November 20, 2023 14:51
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Co-authored-by: kkangh00n <kig2454@gmail.com>
Copy link

@hoon-space hoon-space left a comment

Choose a reason for hiding this comment

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

과제 고생 많으셨습니다.
리뷰 확인 부탁드립니다 ~

*/
@PostMapping("/{postId}")
@Transactional
public ResponseEntity<UpdatePostResponse> updatePost(@PathVariable Long postId, @RequestBody UpdatePostRequest updatePostRequest) {
Copy link

Choose a reason for hiding this comment

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

@RequestBody 에 postId 를 넣는 건 어떤가요 ?

Comment on lines +39 to +42
Long userId = createPostRequest.getUserId();
String title = createPostRequest.getTitle();
String content = createPostRequest.getContent();
Long postId = postService.create(userId, new PostDto(title, content));

Choose a reason for hiding this comment

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

파라미터를 하나하나 뽑아서 넘겨주는 방식이라면, mapper function 을 사용하는게 깔끔할 것 같아요

Comment on lines +71 to +73
List<FindPostResponse> findPostResponseList = postListDto.getPostDtoList().stream()
.map(it -> new FindPostResponse(it.getId(), it.getTitle(), it.getContent()))
.collect(Collectors.toList());

Choose a reason for hiding this comment

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

요런 개체 프로세싱 작업은 서비스 레이어나 별도 메서드로 빼는 건 어떤가요 ??

Comment on lines +12 to +16
public class CreatePostRequest {

private Long userId;
private String title;
private String content;

Choose a reason for hiding this comment

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

DTO 라 @Data 쓰셔도 괜찮을 것 같아요


int count;

List<FindPostResponse> findPostResponseList;

Choose a reason for hiding this comment

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

보통 변수명에 List 단어를 사용하는 것 보다는 복수형으로 사용해요


@Getter
@Entity
@Table(name = "users")

Choose a reason for hiding this comment

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

테이블 이름을 복수형 / 소문자로 하신 이유가 있을까요

Comment on lines +11 to +20
@Component
@RequiredArgsConstructor
public class initDB {

private final UserService userService;

@PostConstruct
public void init(){
userService.dbinit();
}

Choose a reason for hiding this comment

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

테스트 용도라면 테스트 패키지에 있어도 좋을 것 같아요.
비즈니스 코드에 있는 패키지에는 없어도 될 것 같아요

public Long update(Long postId, String content) {
Post post = postRepository.findById(postId).orElseThrow();
post.setContent(content);
return postId;

Choose a reason for hiding this comment

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

팀미팅때에도 이야기헀지만, 업데이트 ID 만 리턴하는 것은 효율적이지 않은 것 같아요

Comment on lines +25 to +30
@Transactional
public Long create(Long userId, PostDto postDto) {
User user = userRepository.findById(userId).orElseThrow();
Post post = new Post(postDto.getTitle(), postDto.getContent(), user);
Post savedPost = postRepository.save(post);
return savedPost.getId();

Choose a reason for hiding this comment

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

트랜잭션 범위를 줄일 수 있다면 줄이는게 좋은 것 같아요

Comment on lines +1 to +11
spring.datasource.driver-class-name = org.h2.Driver
spring.datasource.url = jdbc:h2:mem:test;MODE=MySQL

spring.jpa.hibernate.ddl-auto = create-drop
spring.jpa.database-platform = org.hibernate.dialect.H2Dialect

spring.datasource.hikari.maximum-pool-size = 4
spring.datasource.hikari.pool-name = H2_TEST_POOL

### FOR DEBUGGING ###
logging.level.org.hibernate.SQL = debug

Choose a reason for hiding this comment

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

요것도 yml 로 작성하면 좋을 것 같아요

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

Successfully merging this pull request may close these issues.

None yet

3 participants