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

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

Hoya324
Copy link
Member

@Hoya324 Hoya324 commented Sep 14, 2023

Copy link
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
Member

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
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
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
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
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
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
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
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
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
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
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
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
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
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