-
Notifications
You must be signed in to change notification settings - Fork 15
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
24-25-Server-Assignment-04_김보민 #13
base: main
Are you sure you want to change the base?
Conversation
@DeleteMapping("/{enrollmentId}") | ||
public ResponseEntity<EnrollmentInfoResponseDto> deleteByEnrollmentId(@PathVariable(name="enrollmentId") Long enrollmentId){ | ||
enrollmentService.deleteByEnrollmentId(enrollmentId); | ||
return new ResponseEntity<>(HttpStatus.OK); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드가 보기 힘들게 개행되어 있는 것 같아요..! 들여쓰고 신경써서 하면 더 보기 좋을 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵
@Builder | ||
public Enrollment(String title, Long date, Student student, Lecture lecture) { | ||
this.title=title; | ||
this.date = date; | ||
this.student = student; | ||
this.lecture = lecture; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class 위에 @builder를 사용할 수도 있는데, 이렇게 메서드로 builder를 한 이유가 무엇일까요?
@OneToMany(mappedBy="lecture", cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<Enrollment> enrollments = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cascade와 orphanRemoval이 무슨 뜻이고 어떻게 설정되어 있는 건가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cascade는 부모 엔티티에서 자식 엔티티에 대한 작업을 수행할 때 작업을 정의하고, orphanRemoval은 부모 엔티티와의 관계가 끊어진 자식 엔티티를 자동으로 삭제하는 역할을 합니다.
public ResponseEntity<LectureInfoResponseDto> updateByLectureId(@PathVariable(name="lectureId") Long lectureId, | ||
@RequestBody LectureSaveRequestDto lectureSaveRequestDto){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
데이터는 한 방법으로도 보낼 수 있는데, @PathVariable과 @RequestBody을 사용하는 이유가 무엇일까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PathVariable은 URL 경로를 식별하기 위해 사용되며, @RequestBody는 사용자가 전송하는 데이터 내용을 json형식으로 나타내여 서버를 보내주어 자바 객체 형태로 매핑해 주는 것을 말합니다. 질문 감사합니다.
참고 -> https://leeeehhjj.tistory.com/51
private Long lectureId; | ||
private String lectureTitle; | ||
|
||
public static EnrollmentInfoResponseDto from(Enrollment enrollment){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네이밍을 왜 from으로 했나요? 보민님의 이유가 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
동균코어님 강의 자료 보고 작성하였습니다. 역할은 엔티티를 dto로 변환해 주는 것들을 모아둔 것의 이름이고, 작성명이 생각이 나지 않아 from으로 작성하였습니다
controller 부분에 있는 ResponseEntity 이 부분이 궁금합니다. 역할이 무엇인가요-> 말 그대로 응답 객체로 HTTP 상태 코드, 응답 본문, HTTP 헤더를 설정할 수 있어요. 이를 통해 클라이언트가 쉽게 확인할 수 있게 값을 전달할 수 있죠! |
현재 충돌 나서 머지가 안 되네요~ 해결 부탁드립니다~ |
Description
Question
Reference
4주차_김동균 코어님의 강의 자료와 구글링을 참고하여 작성하였습니다.