-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FEAT] 데일리 루틴 테마 리스트 조회 #17
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.
코드 너무 잘 봤습니다 짧은 시간이었는데.. 바로 이렇게 개발하시다니 역시 천재 소현..!
@Embedded | ||
private RoutineImage imageInfo; |
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로 만드는 거 가독성이 높아져서 좋은 거 같아요!!
public List<DailyTheme> findAllOrderByNameAsc() { | ||
return queryFactory | ||
.selectFrom(dailyTheme) | ||
.orderBy(dailyTheme.name.asc()) | ||
.fetch(); | ||
} |
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.
findAll 메서드를 많이 사용하고 원하는 칼럼의 순서대로 정렬하고 싶을 때
이때, 함수 이름은 findAllByOrderByColumnDesc 와 같은 식으로 사용한다. Column에는 우리가 원하는 칼럼의 이름을 써주는 것이다. 만약 By를 사용하지 않으면 에러가 발생하게 됩니다.
오호 방금 검색하며 봤는데 JPA 참 신기하군요
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.
@csb9427 맞아요~ 메소드명으로 사용해도 가능하지만 가독성을 위해 QueryDSL을 활용해보았어요!
private final DailyThemeRepository dailyThemeRepository; | ||
|
||
public DailyThemesResponse getThemes() { | ||
val themes = dailyThemeRepository.findAllOrderByNameAsc(); |
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.
여기서 let이 아닌 val를 쓰신 이유가 있나요?? 그냥 궁금해서요!!
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.
@csb9427 엇 자바에도 let이 있나요??(javascript만 존재하는 것으로 압니다!) 우선 val은 lombok에서 지원하는 기능으로, 불변성을 가진 변수를 선언할 때 사용합니다!
![image](https://private-user-images.githubusercontent.com/55437339/295096980-4ed67223-e45a-49ad-a628-4fb21d997265.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU1NjYwODUsIm5iZiI6MTcyNTU2NTc4NSwicGF0aCI6Ii81NTQzNzMzOS8yOTUwOTY5ODAtNGVkNjcyMjMtZTQ1YS00OWFkLWE2MjgtNGZiMjFkOTk3MjY1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA1VDE5NDk0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU1M2M1MTUzOTk2MTljOGY4MWMyZTU4MTJjZmIyN2M0YTAzYWEyNGIxNTY4NjZkN2Y1ZWZiZjA1NjdlNTA0MTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.1kR0OFVc8RbadYA23tC0xMrHgTJMwM020w8PuYSGxdg)
출처: https://partnerjun.tistory.com/53
위 이미지를 포함해서 한 번 직접 검색해보셔도 좋을 것 같아요 :)
또한 lombok의 val로 변수 타입 선언을 통일할지 말지도 함께 정해보면 좋을 것 같아요~
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.
아 ㅋㅋ 나 정신없이 리뷰 달다가 자스랑 착각했나봐요 친절한 설명 감사합니다.. ㅜㅜ
@@ -0,0 +1,20 @@ | |||
package com.soptie.server.common.dto; | |||
|
|||
public record Response( |
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.
수고하셨습니다~!!!
|
||
@GetMapping("/themes") | ||
public ResponseEntity<Response> getThemes() { | ||
val response = dailyRoutineService.getThemes(); |
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을 쓰신 이유가 궁금합니다!
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.
@Chan531
#17 (comment)
승빈님 리뷰에도 답 달아뒀어요! 함께 확인해주시면 좋을 것 같아요 :)
import lombok.*; | ||
|
||
@Service | ||
@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.
service 클래스 작성할 때 @transactional(readonly = true)를 미리 적어놓는 게 낫나요 아니면 필요할 때 적는게 낫나요?? 궁금해서 여쭤봅니다!
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.
@Chan531 아 놓치고 있었는데 언급 감사해요!! 미리 붙여놓는 게 좋아요. 불필요한 트랜잭션을 부르지 않아도 되니까요 :)
✨ Related Issue
📝 기능 구현 명세
🐥 추가적인 언급 사항