Skip to content

Commit

Permalink
Merge branch 'Weekly11' into release/0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yugyeom-ghim committed Nov 11, 2024
2 parents aa30af5 + 682e28f commit 17c43c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/notai/auth/AuthArgumentResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public boolean supportsParameter(MethodParameter parameter) {
}

@Override
public Long resolveArgument(
public Member resolveArgument(
MethodParameter parameter,
ModelAndViewContainer mavContainer,
NativeWebRequest webRequest,
WebDataBinderFactory binderFactory
) {
HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest();
Long memberId = (Long) request.getAttribute("memberId");
return memberRepository.getById(memberId).getId();
return memberRepository.getById(memberId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import notai.document.application.result.DocumentFindResult;
import notai.document.domain.Document;
import notai.document.domain.DocumentRepository;
import notai.member.domain.Member;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -21,8 +22,8 @@ public List<DocumentFindResult> findDocuments(Long folderId) {
return documents.stream().map(this::getDocumentFindResult).toList();
}

public List<DocumentFindResult> findRootDocuments(Long memberId) {
List<Document> documents = documentRepository.findAllByMemberIdAndFolderIdIsNull(memberId);
public List<DocumentFindResult> findRootDocuments(Member member) {
List<Document> documents = documentRepository.findAllByMemberIdAndFolderIdIsNull(member.getId());
return documents.stream().map(this::getDocumentFindResult).toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public DocumentUpdateResult updateDocument(
) {
Document document = documentRepository.getById(documentId);
Member member = memberRepository.getById(memberId);

document.validateOwner(member);

if (!folderId.equals(ROOT_FOLDER_ID)) {
Expand All @@ -72,7 +71,6 @@ public void deleteDocument(
) {
Document document = documentRepository.getById(documentId);
Member member = memberRepository.getById(memberId);

document.validateOwner(member);

if (!folderId.equals(ROOT_FOLDER_ID)) {
Expand All @@ -94,8 +92,8 @@ public void deleteAllByFolder(
private Document saveAndReturnDocument(
Long memberId, Long folderId, DocumentSaveRequest documentSaveRequest, PdfSaveResult pdfSaveResult
) {
Member member = memberRepository.getById(memberId);
Folder folder = folderRepository.getById(folderId);
Member member = memberRepository.getById(memberId);
Document document = new Document(folder,
member,
documentSaveRequest.name(),
Expand Down

0 comments on commit 17c43c7

Please sign in to comment.