Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request-template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ☝️Issue Number
close # 이슈번호
closes # 이슈번호

## 📌 개요

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,11 @@ public FolderResponseDto.Create create(Long workspaceId, FolderRequestDto.Create
}
}

// [4] 같은 부모 안에 동일한 이름의 폴더 존재하는지 확인
if (folderRepository.existsByWorkspaceIdAndParentIdAndName(workspaceId, parentId, requestDto.name())) {
throw new FolderException(FolderErrorCode.DUPLICATE_FOLDER_NAME);
}
// [4] 같은 부모 안에 중복되지 않는 고유한 폴더명 생성
String uniqueFolderName = generateUniqueFolderName(workspaceId, parentId, requestDto.name());

// [5] 폴더 생성 - parentId를 업데이트된 값으로 사용, 올바른 workspaceMemberId 사용
FolderRequestDto.Create updatedRequestDto = new FolderRequestDto.Create(parentId, requestDto.name());
FolderRequestDto.Create updatedRequestDto = new FolderRequestDto.Create(parentId, uniqueFolderName);
Folder folder = folderRepository.save(FolderConverter.toFolder(workspaceId, updatedRequestDto, workspaceMember.getId()));
folderClosureCommandService.updateOnCreate(parentId, folder.getId());
return FolderConverter.toFolderResponse(folder);
Expand Down Expand Up @@ -354,6 +352,19 @@ public FolderResponseDto.Message hardDeleteFolder(Long workspaceId, Long folderI
return new FolderResponseDto.Message("폴더가 완전히 삭제되었습니다.");
}

// 같은 부모 폴더 내에서 중복되지 않는 고유한 폴더명 생성 (1), (2) .. 순차 증가
private String generateUniqueFolderName(Long workspaceId, Long parentId, String originalName) {
String uniqueName = originalName;
int counter = 1;

while (folderRepository.existsByWorkspaceIdAndParentIdAndNameAndDeletedAtIsNull(workspaceId, parentId, uniqueName)) {
uniqueName = originalName + "(" + counter + ")";
counter++;
}

return uniqueName;
}

// 삭제된 폴더의 하위 폴더들을 재귀적으로 찾는 헬퍼 메서드
private List<Long> findDeletedDescendants(Long folderId) {
List<Long> allIds = new java.util.ArrayList<>();
Expand Down