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

✨ [Feature] 마신 음료에 대한 당 기록 기능을 구현했어요. #50

Merged
merged 6 commits into from
Jul 7, 2023

Conversation

parkje0927
Copy link
Collaborator

❗️관련 이슈번호

Close #41

⚙️ 어떤 기능을 개발했나요?

  • 유저가 마신 음료에 대한 당 기록을 구현했어요.

🙋🏻 어떤 부분에 집중하여 리뷰해야 할까요?

  • 기록 후 반환하는 내용이 dailyStatistics 부분과 유사해서 DrinkController 에 만들지 고민을 했습니다. 그래도 DrinkController 가 나중에 비대해질 수 있다고 판단하여 record 패키지로 분리했어요.
  • 또한, 오늘 마신 당 섭취량 및 초과 여부를 계산하는 부분은 제준님께서 설계해주신 내용을 참고하여 만들었는데, 로직 중복을 피하기 위해 고민을 했지만 조금씩 기능들이 달라 중복된 부분을 처리하기가 조금 애매한 지점이 있었어요.

@parkje0927 parkje0927 added ✨ Feature 새로운 기능 구현에 관련된 내용입니다. 🌷정현🌷 담당자 : 정현 labels Jul 7, 2023
@parkje0927 parkje0927 self-assigned this Jul 7, 2023
@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Test Results

26 tests   26 ✔️  3s ⏱️
16 suites    0 💤
16 files      0

Results for commit 9fc7217.

♻️ This comment has been updated with latest results.

@parkje0927 parkje0927 linked an issue Jul 7, 2023 that may be closed by this pull request
1 task
Comment on lines 8 to 14
@Builder
public record DrinkRecordSaveRequest(

@NotNull
@Schema(description = "음료 ID", example = "1") Long id,

@NotNull
Copy link
Collaborator

Choose a reason for hiding this comment

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

Notion 명세서에서는 drinkId로 나와있는데 통일하면 좋을것 같아요~

Comment on lines +18 to +21
@NotNull
@Min(0)
@Schema(description = "1잔 기준 최종 섭취 당 함량", example = "10") Integer intakeSugar

Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 부분도 Notion 에는 finalSugar 로 나와있네요~

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

아 넵 노션에 response 만 수정하고 이 부분을 놓쳤네요.
알려주셔서 감사합니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

id 는 drinkId 가 더 직관적인 것 같아서 이렇게 수정했고, 섭취한 당의 경우 RecordEntity 의 필드값과 통일하는 것이 좋을듯 하여 intakeSugar 로 변경했습니다.

Comment on lines 43 to 52
@Override
@Transactional(readOnly = true)
public RecordEntity findRecordById(Long id) {
return queryFactory.selectFrom(recordEntity)
.join(recordEntity.drink, drinkEntity).fetchJoin()
.join(recordEntity.drink.franchise, franchiseEntity).fetchJoin()
.where(recordEntity.member.id.eq(id))
.fetchOne();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional 처리는 필요가 없을까요??

Suggested change
@Override
@Transactional(readOnly = true)
public RecordEntity findRecordById(Long id) {
return queryFactory.selectFrom(recordEntity)
.join(recordEntity.drink, drinkEntity).fetchJoin()
.join(recordEntity.drink.franchise, franchiseEntity).fetchJoin()
.where(recordEntity.member.id.eq(id))
.fetchOne();
}
}
@Override
@Transactional(readOnly = true)
public Optional<RecordEntity> findRecordById(Long id) {
RecordEntity recordEntity = queryFactory.selectFrom(QRecordEntity.recordEntity)
.join(QRecordEntity.recordEntity.drink, QDrinkEntity.drinkEntity).fetchJoin()
.join(QRecordEntity.recordEntity.drink.franchise, QFranchiseEntity.franchiseEntity).fetchJoin()
.where(QRecordEntity.recordEntity.member.id.eq(id))
.fetchOne();
return Optional.ofNullable(recordEntity);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵넵 당장은 비즈니스 로직에 사용하지 않지만 추후 활용을 위해 Optional 처리를 해주는 것이 좋을 것 같습니다.
수정하겠습니다!

@parkje0927 parkje0927 merged commit abdc4d5 into develop Jul 7, 2023
3 checks passed
@parkje0927 parkje0927 deleted the feat/#41 branch July 7, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 새로운 기능 구현에 관련된 내용입니다. 🌷정현🌷 담당자 : 정현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] 마신 음료에 대한 당 기록 기능을 구현해요.
3 participants