Skip to content

[10주차] COW JPA API 개발 미션(Hoya324)#5

Open
Hoya324 wants to merge 18 commits intoCOW-edu:mainfrom
Hoya324:main
Open

[10주차] COW JPA API 개발 미션(Hoya324)#5
Hoya324 wants to merge 18 commits intoCOW-edu:mainfrom
Hoya324:main

Conversation

@Hoya324
Copy link
Copy Markdown
Member

@Hoya324 Hoya324 commented Sep 14, 2023

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.

해당 수정사항 잘 반영 부탁드립니다!

private final MemberService memberService;

@PostMapping("/new")
public MemberResponse create(@Valid @RequestBody MemberRequest memberRequest) {
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.

ResponseEntity 적용을 한번 고려해보면 좋을 듯

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.

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.

return ResponseEntity.created()~~~

import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
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.


private final MemberRepository memberRepository;

public MemberResponse join(MemberRequest memberRequest) {
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.

parameter에 final을 사용하라.

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.

updatePostWriter(request);
}

private void updatePostWriter(UpdateMemberRequest request) {
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.

이것도 네이밍 고려

private final PostService postService;

@PostMapping("/new")
public PostResponse post(@PathVariable Long memberId, @Valid @RequestBody PostRequest postRequest) {
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.

PostRequest : 요청 DTO인데, 엔티티로의 변환이 서비스에서 이루어짐. BUT, 응답을 받아올 때 entity -> 응답 dto로의 변환은 Controller에서 이뤄지고 있음.

@Transactional(readOnly = true)
public Post findPost(Long postId) {
return postRepository.findById(postId)
.orElseThrow(() -> new IllegalArgumentException("사용자가 존재하지 않습니다."));
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.

에러 처리 형식을 맞추자


public void delete(Long memberId, Long postId) throws Exception {
Member member = memberService.findOne(memberId);
List<Post> posts = member.getPosts();
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.

post에서 member를 가져와야함.

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.

Post post = postRepository.findById(postId);

Comment on lines +2 to +6
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
url: jdbc:mysql://localhost:3306/cow_session
password: Gh852852!
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.

yml파일의 컬럼을 git에 그대로 등록하면 pw, key 노출 가능성이 있다. 어떻게 할까?

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.

암호화라던가 뭐 아니면 저런 yml파일을 관리하는 방식을 공부할 필요가 있을 것 같다.

Comment on lines +6 to +13
@SpringBootTest
class JpapracticeApplicationTests {

@Test
void contextLoads() {
}

}
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.

테스트 짜기.


@Entity
@Getter
@NoArgsConstructor
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.

accessLevel

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