Skip to content

Commit

Permalink
[SPR-176] feat: 특정 유저 프로필 조회 및 홈짐 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
yerim216 authored Feb 20, 2024
1 parent fca143b commit 66b7a1b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,17 @@ public ResponseEntity<String> updateFcmToken(@CurrentUser User currentUser, @Req
public ResponseEntity<UserProfileDetailInfo> getUserMyPageProfile(@CurrentUser User currentUser){
return ResponseEntity.ok(userService.getUserMyPageProfile(currentUser));
}

@GetMapping("/profile/{userId}")
@SwaggerApiError({ErrorStatus._EMPTY_USER})
@Operation(summary = "특정 유저 프로필 조회")
public ResponseEntity<UserFollowDetailInfo> getUserMyPageProfile(@CurrentUser User currentUser, @PathVariable Long userId){
return ResponseEntity.ok(userService.getOtherUserMyPageProfile(currentUser, userId));
}

@GetMapping("/home/homegyms/{userId}")
@Operation(summary = "특정 유저 홈짐 조회")
public ResponseEntity<List<UserHomeGymSimpleInfo>> getHomeGyms(@CurrentUser User currentUser, @PathVariable Long userId){
return ResponseEntity.ok(userService.getUserHomeGyms(userId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ public List<UserHomeGymSimpleInfo> getHomeGyms(User currentUser) {
}).toList();

}
public List<UserHomeGymSimpleInfo> getUserHomeGyms(Long userId) {
List<FollowRelationship> followRelationships = followRelationshipRepository.findByFollowerId(
userId);

return followRelationships.stream()
.filter(followRelationship -> followRelationship.getFollowing() instanceof Manager)
.map(followRelationship -> {
ClimbingGym climbingGym = ((Manager) followRelationship.getFollowing()).getClimbingGym();
return UserHomeGymSimpleInfo.toDTO(climbingGym);
}).toList();

}


public UserAccountDetailInfo getLoginUserProfiles(User currentUser) {
Expand Down Expand Up @@ -250,6 +262,22 @@ public UserProfileDetailInfo getUserMyPageProfile(User currentUser){

}

public UserFollowDetailInfo getOtherUserMyPageProfile(User currentUser, Long userId){
User user = userRepository.findById(currentUser.getId())
.orElseThrow(()-> new GeneralException(ErrorStatus._EMPTY_USER));

boolean status = false;
if (followRelationshipRepository.findByFollowerIdAndFollowingId(
currentUser.getId(), userId).isPresent()){
status = true;

}


return UserFollowDetailInfo.toDTO(user, status);

}

@Transactional
public void updateUserFcmToken(User user, String token){
user.updateFCMToken(token);
Expand Down

0 comments on commit 66b7a1b

Please sign in to comment.