Repository navigation
[FEAT] 사용자 프로필 조회 및 관리 API 구현 #47
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
83602b3
feat: 프로필 Repository 6개 추가 (#39)
p1001q a2c3f0d
feat: 프로필 에러 코드 4개 추가 (#39)
p1001q 04ffe98
feat: PIANO 악기 시드 데이터 추가 (#39)
p1001q e99d1f1
feat: 프로필 조회 API 구현 (#39)
p1001q fe98864
feat: 프로필 최초 등록 API 구현 (#39)
p1001q 5d3a2c1
feat: 프로필 수정 API 구현 (#39)
p1001q e8c44c1
test: 프로필 API 컨트롤러 테스트 추가 (#39)
p1001q 4a8642a
fix: 프로필 조회 시 활성 구독만 조회하도록 수정 (#39)
p1001q 73b8684
fix: 시드 동시 실행 시 중복 저장 안전 처리 (#39)
p1001q da3f6d2
fix: 닉네임 중복 검사를 엔티티 변경 전으로 이동 (#39)
p1001q 8403213
fix: 온보딩 동시 요청 시 중복 생성 방지 (#39)
p1001q 8fdd0e3
fix: 구독등급 타입을 String으로 통일하고 값 검증 추가 (#39)
p1001q 3eca142
fix: IllegalStateException을 GeneralException으로 교체 (#39)
p1001q e445c83
fix: 시드 실행에서 트랜잭션 오염 문제 해결 (#39)
p1001q 825a92c
fix: 시드 실행에서 트랜잭션 오염 문제 해결 (#39)
p1001q 32daad5
fix: 시드 중복키 외 무결성 오류는 그대로 전파 (#39)
p1001q da5c092
fix: 구독등급 검증 순서 및 Student 저장 방식 개선 (#39)
p1001q a61f637
docs: 프로필 API 스웨거 설명 추가 (#39)
p1001q 47c6fbf
Merge remote-tracking branch 'origin/develop' into feat/#39-user-prof…
p1001q ef97044
fix: 닉네임 trim을 한 곳에서 처리하도록 정리 (#39)
p1001q 67ba529
refactor: DTO를 req/res 패키지로 분리 (#39)
p1001q 600940b
fix: 온보딩 구독 등급을 요청값 대신 서버에서 PRO로 고정 (#39)
p1001q ad9a833
fix: 닉네임/온보딩 동시성 예외를 SQLState로 구분해 처리 (#39)
p1001q f824f11
refactor: 동시성 예외 판별 분기를 긍정문으로 정리 (#39)
p1001q 7c17409
feat: completedLearningCount를 실제 집계값으로 연동 (#39)
p1001q 9a53f66
fix: 프로필 수정 API를 부분 수정 방식으로 변경 (#39)
p1001q 7d8ab2f
Merge branch 'develop' into feat/#39-user-profile-api
p1001q File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/main/java/com/mr/domain/statistics/repository/UserStatisticsRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.mr.domain.statistics.repository; | ||
|
|
||
| import com.mr.domain.statistics.entity.UserStatistics; | ||
| import java.util.Optional; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface UserStatisticsRepository extends JpaRepository<UserStatistics, Long> { | ||
|
|
||
| Optional<UserStatistics> findByUserId(Long userId); | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/mr/domain/subscriptions/entity/enums/SubscriptionTier.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.mr.domain.subscriptions.entity.enums; | ||
|
|
||
| public enum SubscriptionTier { | ||
| FREE, | ||
| STANDARD, | ||
| PRO | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
src/main/java/com/mr/domain/subscriptions/repository/SubscriptionRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.mr.domain.subscriptions.repository; | ||
|
|
||
| import com.mr.domain.subscriptions.entity.Subscription; | ||
| import com.mr.domain.user.entity.User; | ||
| import java.util.Optional; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface SubscriptionRepository extends JpaRepository<Subscription, Long> { | ||
|
|
||
| Optional<Subscription> findFirstByUserOrderByStartDateDesc(User user); | ||
|
p1001q marked this conversation as resolved.
Resolved
|
||
| } | ||
26 changes: 26 additions & 0 deletions
26
src/main/java/com/mr/domain/user/config/InstrumentSeeder.java
|
p1001q marked this conversation as resolved.
Resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.mr.domain.user.config; | ||
|
|
||
| import com.mr.domain.user.entity.Instrument; | ||
| import com.mr.domain.user.repository.InstrumentRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.boot.ApplicationArguments; | ||
| import org.springframework.boot.ApplicationRunner; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class InstrumentSeeder implements ApplicationRunner { | ||
|
|
||
| private static final String PIANO_CODE = "PIANO"; | ||
| private static final String PIANO_NAME = "피아노"; | ||
|
|
||
| private final InstrumentRepository instrumentRepository; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public void run(ApplicationArguments args) { | ||
| instrumentRepository.findByCode(PIANO_CODE) | ||
| .orElseGet(() -> instrumentRepository.save(Instrument.create(PIANO_CODE, PIANO_NAME))); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
src/main/java/com/mr/domain/user/controller/UserProfileController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.mr.domain.user.controller; | ||
|
|
||
| import com.mr.domain.user.dto.UserProfileRequestDTO; | ||
| import com.mr.domain.user.dto.UserProfileResponseDTO; | ||
| import com.mr.domain.user.service.UserProfileService; | ||
| import com.mr.global.apipayload.ApiResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PatchMapping; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.ResponseStatus; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/users/me/profile") | ||
| public class UserProfileController { | ||
|
|
||
| private final UserProfileService userProfileService; | ||
|
|
||
| @GetMapping | ||
| public ApiResponse<UserProfileResponseDTO.ProfileResponse> getMyProfile() { | ||
| return ApiResponse.onSuccess(userProfileService.getMyProfile()); | ||
| } | ||
|
|
||
| @PostMapping | ||
| @ResponseStatus(HttpStatus.CREATED) | ||
| public ApiResponse<UserProfileResponseDTO.OnboardingResponse> registerProfile( | ||
| @RequestBody UserProfileRequestDTO.OnboardingRequest request | ||
|
p1001q marked this conversation as resolved.
Resolved
|
||
| ) { | ||
| return ApiResponse.onSuccess(userProfileService.registerProfile(request)); | ||
| } | ||
|
|
||
| @PatchMapping | ||
| public ApiResponse<UserProfileResponseDTO.UpdateResponse> updateProfile( | ||
| @RequestBody UserProfileRequestDTO.UpdateRequest request | ||
| ) { | ||
| return ApiResponse.onSuccess(userProfileService.updateProfile(request)); | ||
| } | ||
| } | ||
|
p1001q marked this conversation as resolved.
Resolved
|
||
18 changes: 18 additions & 0 deletions
18
src/main/java/com/mr/domain/user/dto/UserProfileRequestDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.mr.domain.user.dto; | ||
|
|
||
| import com.mr.domain.subscriptions.entity.enums.SubscriptionTier; | ||
| import com.mr.domain.user.entity.enums.TheoryLevel; | ||
|
|
||
| public class UserProfileRequestDTO { | ||
|
|
||
| public record OnboardingRequest( | ||
| String nickname, | ||
| TheoryLevel skillLevel, | ||
| SubscriptionTier subscriptionTier | ||
| ) {} | ||
|
|
||
| public record UpdateRequest( | ||
| String nickname, | ||
| TheoryLevel skillLevel | ||
| ) {} | ||
| } |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/mr/domain/user/dto/UserProfileResponseDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.mr.domain.user.dto; | ||
|
|
||
| import com.mr.domain.user.entity.enums.TheoryLevel; | ||
| import java.time.LocalDateTime; | ||
| import lombok.Builder; | ||
|
|
||
| public class UserProfileResponseDTO { | ||
|
|
||
| @Builder | ||
| public record ProfileResponse( | ||
| String nickname, | ||
| String profileImgUrl, | ||
| String instrumentType, | ||
| TheoryLevel skillLevel, | ||
| String subscriptionTier, | ||
| StatisticsResponse statistics | ||
| ) {} | ||
|
|
||
| @Builder | ||
| public record StatisticsResponse( | ||
| Long practiceSessionCount, | ||
| Long totalPracticeMinutes, | ||
| Long completedLearningCount | ||
| ) {} | ||
|
|
||
| @Builder | ||
| public record OnboardingResponse( | ||
| Long userId, | ||
| String nickname, | ||
| TheoryLevel skillLevel, | ||
| String instrumentType, | ||
| String subscriptionTier, | ||
| String profileImgUrl | ||
| ) {} | ||
|
|
||
| @Builder | ||
| public record UpdateResponse( | ||
| Long userId, | ||
| String nickname, | ||
| TheoryLevel skillLevel, | ||
| LocalDateTime updatedAt | ||
| ) {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/mr/domain/user/repository/InstrumentRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.mr.domain.user.repository; | ||
|
|
||
| import com.mr.domain.user.entity.Instrument; | ||
| import java.util.Optional; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface InstrumentRepository extends JpaRepository<Instrument, Long> { | ||
|
|
||
| Optional<Instrument> findByCode(String code); | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/mr/domain/user/repository/StudentInstrumentRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.mr.domain.user.repository; | ||
|
|
||
| import com.mr.domain.user.entity.Student; | ||
| import com.mr.domain.user.entity.StudentInstrument; | ||
| import java.util.Optional; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface StudentInstrumentRepository extends JpaRepository<StudentInstrument, Long> { | ||
|
|
||
| Optional<StudentInstrument> findByStudentAndPrimaryTrue(Student student); | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/mr/domain/user/repository/StudentRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.mr.domain.user.repository; | ||
|
|
||
| import com.mr.domain.user.entity.Student; | ||
| import com.mr.domain.user.entity.User; | ||
| import java.util.Optional; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface StudentRepository extends JpaRepository<Student, Long> { | ||
|
|
||
| Optional<Student> findByUser(User user); | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/mr/domain/user/repository/UserRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.mr.domain.user.repository; | ||
|
|
||
| import com.mr.domain.user.entity.User; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| // NOTE: feat/#32-learning-status-api(PR #46, 동균 강)에도 동일한 이름의 빈 UserRepository가 있음. | ||
| // 그쪽이 먼저 머지되면 병합 시 이 파일(메서드 포함된 상위호환 버전)로 유지하면 됨. | ||
|
p1001q marked this conversation as resolved.
Resolved
|
||
| public interface UserRepository extends JpaRepository<User, Long> { | ||
|
|
||
| boolean existsByNicknameAndUserIdNot(String nickname, Long userId); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
148 changes: 148 additions & 0 deletions
148
src/main/java/com/mr/domain/user/service/UserProfileService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| package com.mr.domain.user.service; | ||
|
|
||
| import com.mr.domain.subscriptions.entity.Subscription; | ||
| import com.mr.domain.subscriptions.repository.SubscriptionRepository; | ||
| import com.mr.domain.statistics.entity.UserStatistics; | ||
| import com.mr.domain.statistics.repository.UserStatisticsRepository; | ||
| import com.mr.domain.user.dto.UserProfileRequestDTO; | ||
| import com.mr.domain.user.dto.UserProfileResponseDTO; | ||
| import com.mr.domain.user.entity.Instrument; | ||
| import com.mr.domain.user.entity.Student; | ||
| import com.mr.domain.user.entity.StudentInstrument; | ||
| import com.mr.domain.user.entity.User; | ||
| import com.mr.domain.user.exception.StudentErrorStatus; | ||
| import com.mr.domain.user.exception.UserErrorStatus; | ||
| import com.mr.domain.user.repository.InstrumentRepository; | ||
| import com.mr.domain.user.repository.StudentInstrumentRepository; | ||
| import com.mr.domain.user.repository.StudentRepository; | ||
| import com.mr.domain.user.repository.UserRepository; | ||
| import com.mr.global.apipayload.exception.GeneralException; | ||
| import com.mr.global.security.SecurityUtil; | ||
| import java.time.LocalDateTime; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class UserProfileService { | ||
|
|
||
| private static final String PIANO_CODE = "PIANO"; | ||
| private static final int SUBSCRIPTION_PERIOD_DAYS = 30; | ||
|
|
||
| private final UserRepository userRepository; | ||
| private final StudentRepository studentRepository; | ||
| private final StudentInstrumentRepository studentInstrumentRepository; | ||
| private final InstrumentRepository instrumentRepository; | ||
| private final SubscriptionRepository subscriptionRepository; | ||
| private final UserStatisticsRepository userStatisticsRepository; | ||
|
|
||
| public UserProfileResponseDTO.ProfileResponse getMyProfile() { | ||
| Long userId = SecurityUtil.getCurrentUserId(); | ||
| User user = getUser(userId); | ||
| Student student = getStudent(user); | ||
|
|
||
| String instrumentType = studentInstrumentRepository.findByStudentAndPrimaryTrue(student) | ||
| .map(StudentInstrument::getInstrument) | ||
| .map(Instrument::getCode) | ||
| .orElseThrow(() -> new IllegalStateException("대표 악기 정보가 존재하지 않습니다.")); | ||
|
|
||
| String subscriptionTier = subscriptionRepository.findFirstByUserOrderByStartDateDesc(user) | ||
| .map(Subscription::getTier) | ||
| .orElseThrow(() -> new IllegalStateException("구독 정보가 존재하지 않습니다.")); | ||
|
p1001q marked this conversation as resolved.
Resolved
|
||
|
|
||
| return UserProfileResponseDTO.ProfileResponse.builder() | ||
| .nickname(user.getNickname()) | ||
| .profileImgUrl(user.getProfileImgUrl()) | ||
| .instrumentType(instrumentType) | ||
| .skillLevel(student.getTheoryLevel()) | ||
| .subscriptionTier(subscriptionTier) | ||
| .statistics(buildStatistics(userId)) | ||
| .build(); | ||
| } | ||
|
|
||
| @Transactional | ||
| public UserProfileResponseDTO.OnboardingResponse registerProfile(UserProfileRequestDTO.OnboardingRequest request) { | ||
| Long userId = SecurityUtil.getCurrentUserId(); | ||
| User user = getUser(userId); | ||
|
|
||
| if (user.isOnboardingCompleted()) { | ||
| throw new GeneralException(UserErrorStatus.ONBOARDING_ALREADY_COMPLETED); | ||
| } | ||
|
|
||
| user.updateNickname(request.nickname()); | ||
| ensureNicknameNotTaken(user); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| Student student = studentRepository.save(Student.create(user, request.skillLevel())); | ||
|
|
||
| Instrument piano = instrumentRepository.findByCode(PIANO_CODE) | ||
| .orElseThrow(() -> new IllegalStateException("PIANO 악기 시드 데이터가 존재하지 않습니다.")); | ||
| studentInstrumentRepository.save(StudentInstrument.createPrimary(student, piano)); | ||
|
|
||
| String tier = request.subscriptionTier() == null ? null : request.subscriptionTier().name(); | ||
| LocalDateTime now = LocalDateTime.now(); | ||
| Subscription subscription = subscriptionRepository.save( | ||
| Subscription.create(user, tier, now, now.plusDays(SUBSCRIPTION_PERIOD_DAYS))); | ||
|
p1001q marked this conversation as resolved.
Resolved
|
||
|
|
||
| return UserProfileResponseDTO.OnboardingResponse.builder() | ||
| .userId(user.getUserId()) | ||
| .nickname(user.getNickname()) | ||
| .skillLevel(student.getTheoryLevel()) | ||
| .instrumentType(piano.getCode()) | ||
| .subscriptionTier(subscription.getTier()) | ||
| .profileImgUrl(user.getProfileImgUrl()) | ||
| .build(); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| @Transactional | ||
| public UserProfileResponseDTO.UpdateResponse updateProfile(UserProfileRequestDTO.UpdateRequest request) { | ||
| Long userId = SecurityUtil.getCurrentUserId(); | ||
| User user = getUser(userId); | ||
| Student student = getStudent(user); | ||
|
|
||
| user.updateNickname(request.nickname()); | ||
| ensureNicknameNotTaken(user); | ||
| student.updateTheoryLevel(request.skillLevel()); | ||
|
|
||
| return UserProfileResponseDTO.UpdateResponse.builder() | ||
| .userId(user.getUserId()) | ||
| .nickname(user.getNickname()) | ||
| .skillLevel(student.getTheoryLevel()) | ||
| .updatedAt(LocalDateTime.now()) | ||
| .build(); | ||
| } | ||
|
|
||
| private User getUser(Long userId) { | ||
| return userRepository.findById(userId) | ||
| .orElseThrow(() -> new GeneralException(UserErrorStatus.USER_NOT_FOUND)); | ||
| } | ||
|
|
||
| private Student getStudent(User user) { | ||
| return studentRepository.findByUser(user) | ||
| .orElseThrow(() -> new GeneralException(StudentErrorStatus.STUDENT_NOT_FOUND)); | ||
| } | ||
|
|
||
| private void ensureNicknameNotTaken(User user) { | ||
| if (userRepository.existsByNicknameAndUserIdNot(user.getNickname(), user.getUserId())) { | ||
| throw new GeneralException(UserErrorStatus.NICKNAME_DUPLICATED); | ||
| } | ||
| } | ||
|
p1001q marked this conversation as resolved.
Resolved
|
||
|
|
||
| private UserProfileResponseDTO.StatisticsResponse buildStatistics(Long userId) { | ||
| UserStatistics stats = userStatisticsRepository.findByUserId(userId).orElse(null); | ||
|
|
||
| return UserProfileResponseDTO.StatisticsResponse.builder() | ||
| .practiceSessionCount(stats == null ? 0L : stats.getTotalPracticeCount().longValue()) | ||
| .totalPracticeMinutes(stats == null ? 0L : stats.getTotalPracticeMinutes().longValue()) | ||
| .completedLearningCount(countCompletedLearnings(userId)) | ||
| .build(); | ||
| } | ||
|
|
||
| // TODO: feat/#32-learning-status-api(동균 강) 병합 후 UserLearningProgressRepository로 교체 | ||
| // SELECT COUNT(DISTINCT ulp.learning_id) FROM user_learning_progress ulp | ||
| // WHERE ulp.user_id = :userId AND ulp.score >= 90 | ||
| private Long countCompletedLearnings(Long userId) { | ||
| return 0L; | ||
| } | ||
|
p1001q marked this conversation as resolved.
Resolved
|
||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.