Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] pick v2 도메인 개발 #278

Merged
merged 21 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package kernel360.techpick.feature.infrastructure.folder.reader;

import kernel360.techpick.core.model.folder.Folder;
import kernel360.techpick.core.model.user.User;

public interface FolderReader {

Folder read(User user, Long folderId);
Gyaak marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
package kernel360.techpick.feature.infrastructure.folder.reader;

import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;

import kernel360.techpick.core.model.folder.Folder;
import kernel360.techpick.core.model.folder.FolderRepository;
import kernel360.techpick.core.model.user.User;
import kernel360.techpick.feature.domain.folder.exception.ApiFolderException;
import lombok.RequiredArgsConstructor;

@Component
@RequiredArgsConstructor
public class FolderReaderImpl implements FolderReader {
FolderRepository folderRepository;

@Override
public Folder read(User user, Long folderId) {
Folder folder = folderRepository.findById(folderId).orElseThrow(ApiFolderException::FOLDER_NOT_FOUND);
if (ObjectUtils.notEqual(folder.getUser(), user)) {
throw ApiFolderException.FOLDER_ACCESS_DENIED();
}
return folder;
}
}