-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/#424 캘린더 도메인에 필요한 api를 개발한다 #438
base: develop
Are you sure you want to change the base?
The head ref may contain hidden characters: "Feature/#424-\uCE98\uB9B0\uB354-\uB3C4\uBA54\uC778\uC5D0-\uD544\uC694\uD55C-API\uB97C-\uAC1C\uBC1C\uD55C\uB2E4"
Conversation
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.
@Test | ||
@Disabled | ||
@DisplayName("썸네일 저장 시 type이 null이면 NullPointerException을 발생시킨다.") |
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.
이 테스트는 왜 @disabled 처리 하셨나용?
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.
퀵스타트 만들 때도 그렇고 항상 이 테스트가 깨졌습니다. 다른 분들은 통과 하시는지 궁금하네요..!! 메서드 들어가보면 null이면 NPE을 throw 하는게 아니라 optional empty로 반환해서 테스트가 깨지는 것 같습니다!
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 ScheduleType( | ||
|
||
@Column(name = "type", nullable = false) | ||
val type: String, | ||
|
||
@Column(name = "description", nullable = false) | ||
val description: String, | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long?, | ||
) |
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.
inner enum class로 타입을 명시해두면 코드 가독성이 더 올라가지 않을까 합니다!
ex) MemberJob
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.
좋습니다~! 감사합니다
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long? = null, |
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.
val id: Long? = null, | |
val id: Long = 0 |
Nit: 어떨까요?!
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.
저도 이 부분이 너무 헷갈리는데 다른 곳과 다른 분들은 어떻게 생각하시는지 궁금합니다.
코틀린 강의를 봤을 때는 nullable type을 사용하셨고 아래의 질문 게시판을 보니 nullable type 사용 이유를 설명해 주셨습니다. nullable type을 쓰면 테스트 코드 작성 등에서 !!을 계속 붙여줘야 해서 불편하다고 느꼈습니다.. 하지만 하이버네이트가 nullable type을 추천한다고 합니다.
아래 게시판을 보시고 의견 남겨주시면 감사하겠습니다..!!
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.
아하 하이버네이트가 nullable 타입을 추천하는군요... 처음 알았습니다!
엔티티의 필드를 Wrapper로 선언하는 것과 동일한 맥락이겠죠? 그렇다면 코드를 작성할 때 조금 번거롭더라도 Long?
으로 선언하는 것도 좋아보입니다!
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
class ScheduleService( | ||
val scheduleRepository: ScheduleRepository, | ||
val scheduleTypeRepository: ScheduleTypeRepository, | ||
) { |
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.
코틀린에서는 @RequiredArgsConstructor
가 없어도 동작하는 걸로 알고 있습니다!
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.
보름님 말씀대로 RequiredArgsConstructor 필요 없습니다!
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.
GOD Kt..
endTime: LocalDateTime, scheduleTypeId: Long, | ||
): Long { | ||
val findSchedule = scheduleTypeRepository.findByIdOrNull(scheduleTypeId) | ||
?: throw IllegalArgumentException("ScheduleType not found") |
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.
Nit: 다른 코드들과 통일성 있게 커스텀 예외를 등록해두는 건 어떨까요?
fun saveSchedule(name: String, startTime: LocalDateTime, | ||
endTime: LocalDateTime, scheduleTypeId: Long, | ||
): Long { |
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.
fun saveSchedule(name: String, startTime: LocalDateTime, | |
endTime: LocalDateTime, scheduleTypeId: Long, | |
): Long { | |
fun saveSchedule( | |
name: String, | |
startTime: LocalDateTime, | |
endTime: LocalDateTime, | |
scheduleTypeId: Long, | |
): Long { |
너무나 사소하지만... 저는 이렇게 포맷팅하지 않으면 불편한 병에 걸렸습니다 ㅎㅎ 🤣 (코틀린 권장 스타일이긴 하더라구요!)
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.
저도 이 부분을 5번 정도 지웠다 했는데 다시 보니 코틀린 권장 스타일이 좋을 것 같습니다 bb
감사합니다
|
||
@Validated | ||
@RestController | ||
@RequestMapping("/schedule") |
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.
@RequestMapping("/schedule") | |
@RequestMapping("/schedules") |
복수형 어떨까욥!
saveScheduleRequest.scheduleTypeId | ||
) | ||
|
||
return ResponseEntity.ok().build() |
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.
데이터를 생성하는 api이니, 201 Created 응답코드를 반환하는 건 어떨까요?
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.
아 그렇네요 감사합니다
return scheduleRepository.save( | ||
Schedule( | ||
name = name, | ||
startTime = startTime, | ||
endTime = endTime, | ||
scheduleType = findSchedule, | ||
) | ||
).id!! |
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.
startTime
이 endTime
보다 앞선 시간이 맞는 지도 검증해보면 좋을 것 같습니다!
+) 세미나 도메인에도 비슷한 검증 로직이 있어서, 커스텀 어노테이션을 하나 만들어서 재사용하는 것도 좋을 것 같네요!!
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.
수고하셨습니다🔥
저도 빨리 도서관 도메인 끝내고 캘린더 하러 가겠습니당~~!!
좋은코드 잘 봤습니당!!
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
class ScheduleService( | ||
val scheduleRepository: ScheduleRepository, | ||
val scheduleTypeRepository: ScheduleTypeRepository, | ||
) { |
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.
보름님 말씀대로 RequiredArgsConstructor 필요 없습니다!
|
||
@Transactional | ||
fun saveSchedule(name: String, startTime: LocalDateTime, | ||
endTime: LocalDateTime, scheduleTypeId: Long, |
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.
개인적으로 편의상 endTime의 default 값을 startTime + 1로 잡아두는 것은 어떨까욤??
코틀린은 가능합니다!! endTime:LocalDateTime?= startTime.addDate(1)
같이요! ㅎㅎ 보통 일정은 하루로 등록할 일이 많다고 생각합니당 :D
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.
그렇네요.. 보통 디폴트 날짜는 보통 하루겠네요~ 감사합니다
|
||
data class SaveScheduleRequest( | ||
|
||
@NotEmpty(message = "일정 이름을 입력해주세요.") |
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.
이거 혹시 동작하나요?? 코틀린은 @field:xxx
방식으로 달아줘야하는 것으로 알고있습니당!
🔥 Related Issue
#424
📝 Description
캘린더 도메인 CRUD 중 C 부분 개발을 완료했습니다.
+)
Read 부분과 KEEPER DSL이 머지되면 Controller 테스트와 예외 테스트까지 작성하도록 하겠습니다.
⭐️ Review Request