Skip to content

Commit

Permalink
✨ Feat: 친구 카테고리 정보 조회 API 구현 완료
Browse files Browse the repository at this point in the history
<body>
친구관계에 있는 친구를 가져와 카테고리 정보를 return 하는 API 구현 (공개 된 카테고리만 조회)

- 관련 : #397
  • Loading branch information
hosung-222 committed Oct 29, 2024
1 parent e7ff259 commit da09649
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ public ResponseDto<String> deleteFriend(
return ResponseDto.onSuccess("친구 삭제 완료");
}

@Operation(summary = "친구의 스케줄 카테고리 정보를 조회", description = "친구가 등록한 카테고리를 조회합니다(공개된 카테고리만 조회됩니다)")
@GetMapping("/{friendId}/categories")
public ResponseDto<List<FriendCategoryResponse.CategoryInfoDto>> getFriendCategories(
@AuthenticationPrincipal SecurityUserDetails member,
@Parameter(description = "카테고리를 조회 할 친구의 memberId를 입력해주세요", example = "1")
@PathVariable Long friendId
){
return ResponseDto.onSuccess(null);
return ResponseDto.onSuccess(friendUseCase
.getFriendCategories(member.getUserId(), friendId));
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.namo.spring.application.external.api.user.usecase;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.namo.spring.application.external.api.user.converter.FriendCategoryConverter;
import com.namo.spring.application.external.api.user.converter.FriendshipConverter;
import com.namo.spring.application.external.api.user.dto.FriendCategoryResponse;
import com.namo.spring.application.external.api.user.dto.FriendshipResponse;
import com.namo.spring.application.external.api.user.service.FriendManageService;
import com.namo.spring.application.external.api.user.service.MemberManageService;
import com.namo.spring.db.mysql.domains.category.entity.Category;
import com.namo.spring.db.mysql.domains.user.entity.Friendship;
import com.namo.spring.db.mysql.domains.user.entity.Member;

Expand Down Expand Up @@ -64,4 +69,14 @@ public void deleteFriend(Long memberId, Long friendId) {
Friendship reversedTarget = friendManageService.getAcceptedFriendship(friendId, memberId);
friendManageService.deleteFriendShip(target, reversedTarget);
}

@Transactional(readOnly = true)
public List<FriendCategoryResponse.CategoryInfoDto> getFriendCategories(Long memberId, Long friendId) {
Friendship friendship = friendManageService.getAcceptedFriendship(memberId, friendId);
List<Category> friendCategories = friendship.getFriend().getCategories();

return friendCategories.stream()
.map(FriendCategoryConverter::toCategoryInfoDto)
.toList();
}
}

0 comments on commit da09649

Please sign in to comment.