Skip to content

Commit 7f09ece

Browse files
committed
#72 πŸ› fix : 폴더 λͺ©λ‘ 응닡 둜직 μˆ˜μ •
1 parent 1e79f43 commit 7f09ece

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

β€Žsrc/main/java/com/finsight/finsight/domain/storage/domain/service/FolderService.javaβ€Ž

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.finsight.finsight.domain.storage.exception.code.StorageErrorCode;
1111
import com.finsight.finsight.domain.storage.persistence.entity.FolderEntity;
1212
import com.finsight.finsight.domain.storage.persistence.entity.FolderType;
13+
import com.finsight.finsight.domain.storage.persistence.repository.FolderItemRepository;
1314
import com.finsight.finsight.domain.storage.persistence.repository.FolderRepository;
1415
import com.finsight.finsight.domain.user.persistence.entity.UserEntity;
1516
import com.finsight.finsight.domain.user.persistence.repository.UserRepository;
@@ -27,13 +28,17 @@ public class FolderService {
2728
private static final int MAX_FOLDER_COUNT = 10;
2829

2930
private final FolderRepository folderRepository;
31+
private final FolderItemRepository folderItemRepository;
3032
private final UserRepository userRepository;
3133

3234
// 폴더 λͺ©λ‘ 쑰회
3335
public List<FolderResponse> getFolders(Long userId, FolderType folderType) {
3436
List<FolderEntity> folders = folderRepository.findByUserUserIdAndFolderTypeOrderBySortOrderAsc(userId, folderType);
3537
return folders.stream()
36-
.map(FolderResponse::from)
38+
.map(folder -> {
39+
long itemCount = folderItemRepository.countByFolderFolderId(folder.getFolderId());
40+
return FolderResponse.from(folder, itemCount);
41+
})
3742
.toList();
3843
}
3944

@@ -88,7 +93,8 @@ public FolderResponse updateFolder(Long userId, Long folderId, UpdateFolderReque
8893
}
8994

9095
folder.updateFolderName(request.folderName());
91-
return FolderResponse.from(folder);
96+
long itemCount = folderItemRepository.countByFolderFolderId(folder.getFolderId());
97+
return FolderResponse.from(folder, itemCount);
9298
}
9399

94100
// 폴더 μ‚­μ œ

β€Žsrc/main/java/com/finsight/finsight/domain/storage/persistence/repository/FolderItemRepository.javaβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
public interface FolderItemRepository extends JpaRepository<FolderItemEntity, Long> {
1919

20+
// νŠΉμ • ν΄λ”μ˜ μ•„μ΄ν…œ 개수 쑰회
21+
long countByFolderFolderId(Long folderId);
22+
2023
// νŠΉμ • ν΄λ”μ˜ μ•„μ΄ν…œ λͺ©λ‘ 쑰회 (μ΅œμ‹ μˆœ)
2124
Page<FolderItemEntity> findByFolderFolderIdOrderBySavedAtDesc(Long folderId, Pageable pageable);
2225

0 commit comments

Comments
Β (0)