-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit ad9062e.
- Loading branch information
Showing
42 changed files
with
128 additions
and
438 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
package notai.auth; | ||
|
||
public record TokenPair( | ||
String accessToken, | ||
String refreshToken | ||
) { | ||
public record TokenPair(String accessToken, String refreshToken) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
src/main/java/notai/folder/application/FolderQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,9 @@ | ||
package notai.folder.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import notai.folder.application.result.FolderFindResult; | ||
import notai.folder.domain.Folder; | ||
import notai.folder.domain.FolderRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FolderQueryService { | ||
|
||
private final FolderRepository folderRepository; | ||
|
||
public List<FolderFindResult> getFolders(Long memberId, Long parentFolderId) { | ||
List<Folder> folders = getFoldersWithMemberAndParent(memberId, parentFolderId); | ||
// document read | ||
return folders.stream().map(this::getFolderResult).toList(); | ||
} | ||
|
||
private List<Folder> getFoldersWithMemberAndParent(Long memberId, Long parentFolderId) { | ||
if (parentFolderId == null) { | ||
return folderRepository.findAllByMemberIdAndParentFolderIsNull(memberId); | ||
} | ||
return folderRepository.findAllByMemberIdAndParentFolderId(memberId, parentFolderId); | ||
} | ||
|
||
private FolderFindResult getFolderResult(Folder folder) { | ||
Long parentFolderId = folder.getParentFolder() != null ? folder.getParentFolder().getId() : null; | ||
return FolderFindResult.of(folder.getId(), parentFolderId, folder.getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,9 @@ | ||
package notai.folder.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import notai.common.exception.type.BadRequestException; | ||
import notai.folder.application.result.FolderMoveResult; | ||
import notai.folder.application.result.FolderSaveResult; | ||
import notai.folder.domain.Folder; | ||
import notai.folder.domain.FolderRepository; | ||
import notai.folder.presentation.request.FolderMoveRequest; | ||
import notai.folder.presentation.request.FolderSaveRequest; | ||
import notai.member.domain.Member; | ||
import notai.member.domain.MemberRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FolderService { | ||
|
||
private final FolderRepository folderRepository; | ||
private final MemberRepository memberRepository; | ||
|
||
public FolderSaveResult saveRootFolder(Long memberId, FolderSaveRequest folderSaveRequest) { | ||
Member member = memberRepository.getById(memberId); | ||
Folder folder = new Folder(member, folderSaveRequest.name()); | ||
Folder savedFolder = folderRepository.save(folder); | ||
return getFolderSaveResult(savedFolder); | ||
} | ||
|
||
public FolderSaveResult saveSubFolder(Long memberId, FolderSaveRequest folderSaveRequest) { | ||
Member member = memberRepository.getById(memberId); | ||
Folder parentFolder = folderRepository.getById(folderSaveRequest.parentFolderId()); | ||
Folder folder = new Folder(member, folderSaveRequest.name(), parentFolder); | ||
Folder savedFolder = folderRepository.save(folder); | ||
return getFolderSaveResult(savedFolder); | ||
} | ||
|
||
public FolderMoveResult moveRootFolder(Long memberId, Long id) { | ||
Folder folder = folderRepository.getById(id); | ||
folder.validateOwner(memberId); | ||
folder.moveRootFolder(); | ||
folderRepository.save(folder); | ||
return getFolderMoveResult(folder); | ||
} | ||
|
||
public FolderMoveResult moveNewParentFolder(Long memberId, Long id, FolderMoveRequest folderMoveRequest) { | ||
Folder folder = folderRepository.getById(id); | ||
Folder parentFolder = folderRepository.getById(folderMoveRequest.targetFolderId()); | ||
folder.validateOwner(memberId); | ||
folder.moveNewParentFolder(parentFolder); | ||
folderRepository.save(folder); | ||
return getFolderMoveResult(folder); | ||
} | ||
|
||
public void deleteFolder(Long memberId, Long id) { | ||
if (!folderRepository.existsByMemberIdAndId(memberId, id)) { | ||
throw new BadRequestException("올바르지 않은 요청입니다."); | ||
} | ||
folderRepository.deleteById(id); | ||
} | ||
|
||
private FolderSaveResult getFolderSaveResult(Folder folder) { | ||
Long parentFolderId = folder.getParentFolder() != null ? folder.getParentFolder().getId() : null; | ||
return FolderSaveResult.of(folder.getId(), parentFolderId, folder.getName()); | ||
} | ||
|
||
private FolderMoveResult getFolderMoveResult(Folder folder) { | ||
return FolderMoveResult.of(folder.getId(), folder.getName()); | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
src/main/java/notai/folder/application/result/FolderFindResult.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
src/main/java/notai/folder/application/result/FolderMoveResult.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/main/java/notai/folder/application/result/FolderSaveResult.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.