Skip to content

Commit a5772a6

Browse files
authored
Merge pull request #62 from DropThe8bit/feat/profile
[feature] 자녀 프로필 조회 API
2 parents 3794ee3 + b1c6771 commit a5772a6

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/main/java/everTale/everTale_be/domain/profile/controller/ProfileController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,20 @@ public ApiResponse<String> createParentProfile(){
4242

4343
// 프로필 리스트
4444
@Operation(summary = "프로필 리스트 조회", description = "사용자의 프로필 목록을 조회합니다.")
45-
@GetMapping
45+
@GetMapping("/all")
4646
public ApiResponse<ProfileListResponseDto> getProfiles(){
4747
ProfileListResponseDto responseDto = profileService.getProfiles();
4848
return ApiResponse.onSuccess(responseDto);
4949
}
5050

51+
// 자녀 프로필 리스트
52+
@Operation(summary = "자녀 프로필 리스트 조회", description = "사용자의 자녀 프로필 목록을 조회합니다.")
53+
@GetMapping("/child")
54+
public ApiResponse<ProfileListResponseDto> getChildProfiles(){
55+
ProfileListResponseDto responseDto = profileService.getChildProfiles();
56+
return ApiResponse.onSuccess(responseDto);
57+
}
58+
5159
// 프로필 접속
5260
@Operation(summary = "프로필 접속", description = "선택한 프로필에 접속합니다.")
5361
@PostMapping("/{profileId}")

src/main/java/everTale/everTale_be/domain/profile/repository/ProfileRepository.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package everTale.everTale_be.domain.profile.repository;
22

33
import everTale.everTale_be.domain.profile.entity.Enum.ProfileStatus;
4+
import everTale.everTale_be.domain.profile.entity.Enum.ProfileType;
45
import everTale.everTale_be.domain.profile.entity.Profile;
56
import org.springframework.data.jpa.repository.JpaRepository;
67
import org.springframework.data.jpa.repository.Modifying;
@@ -21,6 +22,13 @@ public interface ProfileRepository extends JpaRepository<Profile, Long> {
2122
// 현재 로그인한 회원의 프로필들 가져오기
2223
List<Profile> findAllByUserIdAndProfileStatusNot(Long userId, ProfileStatus status);
2324

25+
// 현재 로그인한 회원의 CHILD 프로필 조회
26+
List<Profile> findAllByUserIdAndProfileStatusNotAndProfileType(
27+
Long userId,
28+
ProfileStatus status,
29+
ProfileType profileType
30+
);
31+
2432
@Modifying
2533
@Transactional
2634
@Query(value = "UPDATE Profile p SET " +

src/main/java/everTale/everTale_be/domain/profile/service/ProfileService.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ public ProfileListResponseDto getProfiles(){
7777
return ProfileListResponseDto.from(profiles);
7878
}
7979

80-
// 프로필 상세정보 조회
80+
81+
@Transactional(readOnly = true)
82+
public ProfileListResponseDto getChildProfiles(){
83+
Long userId = userHelper.getRootUserId();
84+
List<Profile> profiles = profileRepository.findAllByUserIdAndProfileStatusNotAndProfileType(userId, ProfileStatus.DELETED, ProfileType.CHILD);
85+
86+
return ProfileListResponseDto.from(profiles);
87+
}
88+
8189
@Transactional(readOnly = true)
8290
public ProfileInfoResponseDto getProfileInfo(){
8391
Profile profile = profileHelper.getAuthenticatedProfile();

0 commit comments

Comments
 (0)