From 2ece31a1cc26795f2d06f216adc34c75d898a09a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 13:20:27 +0900 Subject: [PATCH 001/101] =?UTF-8?q?refactor(DocumentController):=20url=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit teamId와 foderId가 url에 드러나도록 수정 --- .../tiki/server/document/controller/DocumentController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index 47be9c77..7c8cf5cb 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -57,10 +57,11 @@ public ResponseEntity deleteDocument( return ResponseEntity.noContent().build(); } - @PostMapping("/documents") + @PostMapping("/teams/{teamId}/documents") public ResponseEntity> createDocuments( Principal principal, - @RequestHeader("team-id") long teamId, + @PathVariable long teamId, + @RequestParam(required = false) long folderId, @RequestBody DocumentsCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); From 543fa1475511cf8bc21c04cf6ab64f20949cab68 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 13:21:36 +0900 Subject: [PATCH 002/101] =?UTF-8?q?chore(DocumentController):=20created=20?= =?UTF-8?q?URI=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/controller/DocumentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index 7c8cf5cb..821f1b46 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -66,7 +66,7 @@ public ResponseEntity> createDocuments( ) { long memberId = Long.parseLong(principal.getName()); DocumentsCreateResponse response = documentService.createDocuments(memberId, teamId, request); - return ResponseEntity.created(UriGenerator.getUri("api/v1/documents")) + return ResponseEntity.created(UriGenerator.getUri("teams/" + teamId + "/documents")) .body(SuccessResponse.success(SUCCESS_CREATE_DOCUMENTS.getMessage(), response)); } From 2450ed92329a8e017b2959a8247dc5cf18627e56 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 13:22:44 +0900 Subject: [PATCH 003/101] =?UTF-8?q?chore(DocumentController):=20folderId?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/controller/DocumentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index 821f1b46..e26ced15 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -61,7 +61,7 @@ public ResponseEntity deleteDocument( public ResponseEntity> createDocuments( Principal principal, @PathVariable long teamId, - @RequestParam(required = false) long folderId, + @RequestParam(required = false) Long folderId, @RequestBody DocumentsCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); From 57f419e001255c01d85c661450a1973d7634fad4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 13:52:53 +0900 Subject: [PATCH 004/101] =?UTF-8?q?feat(DocumentService):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 폴더의 팀 id 검증 --- .../server/document/service/DocumentService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 7d10c34c..9020b96e 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -1,5 +1,7 @@ package com.tiki.server.document.service; +import static com.tiki.server.document.message.ErrorCode.INVALID_AUTHORIZATION; + import java.util.List; import org.springframework.stereotype.Service; @@ -14,7 +16,9 @@ import com.tiki.server.document.dto.response.DocumentsCreateResponse; import com.tiki.server.document.dto.response.DocumentsGetResponse; import com.tiki.server.document.entity.Document; +import com.tiki.server.document.exception.DocumentException; import com.tiki.server.folder.adapter.FolderFinder; +import com.tiki.server.folder.entity.Folder; import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; import com.tiki.server.memberteammanager.entity.MemberTeamManager; @@ -49,6 +53,7 @@ public void deleteDocument(long memberId, long teamId, long documentId) { @Transactional public DocumentsCreateResponse createDocuments(long memberId, long teamId, DocumentsCreateRequest request) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); + validateFolder(request.folderId(), teamId); checkFolderIsExist(request.folderId()); List documentIds = request.documents().stream() .map(document -> saveDocument(teamId, request.folderId(), document).getId()) @@ -67,6 +72,16 @@ private DocumentsGetResponse getAllDocumentsByType(long teamId, Position accessi return DocumentsGetResponse.from(documents); } + private void validateFolder(Long folderId, long teamId) { + if (folderId == null) { + return; + } + Folder folder = folderFinder.findById(folderId); + if (folder.getTeamId() != teamId) { + throw new DocumentException(INVALID_AUTHORIZATION); + } + } + private void checkFolderIsExist(Long folderId) { if (folderId == null) { return; From 5e3865ab42e86b1ade6c3d6e72ee09f7e37df644 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 13:53:22 +0900 Subject: [PATCH 005/101] =?UTF-8?q?feat(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=9D=B4=EB=A6=84=20=EC=A4=91=EB=B3=B5=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/service/DocumentService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 9020b96e..d27f3446 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -54,10 +54,12 @@ public void deleteDocument(long memberId, long teamId, long documentId) { public DocumentsCreateResponse createDocuments(long memberId, long teamId, DocumentsCreateRequest request) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); validateFolder(request.folderId(), teamId); + List documents = documentFinder.findByTeamIdAndFolderId(teamId, request.folderId()); checkFolderIsExist(request.folderId()); List documentIds = request.documents().stream() - .map(document -> saveDocument(teamId, request.folderId(), document).getId()) - .toList(); + .filter(document -> checkFileNameIsNotDuplicated(document.fileName(), documents)) + .map(document -> saveDocument(teamId, request.folderId(), document).getId()) + .toList(); return DocumentsCreateResponse.from(documentIds); } @@ -94,4 +96,9 @@ private Document saveDocument(long teamId, Long folderId, DocumentCreateRequest request.fileName(), request.fileUrl(), request.capacity(), teamId, folderId); return documentSaver.save(document); } + + private boolean checkFileNameIsNotDuplicated(final String fileName, final List documents) { + return documents.stream() + .noneMatch(document -> document.getFileName().equals(fileName)); + } } From 44c02602b6853574649fa28410d80ad102b752ba Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:20:55 +0900 Subject: [PATCH 006/101] =?UTF-8?q?feat(ErrorCode):=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EB=90=9C=20=ED=8C=8C=EC=9D=BC=20=EC=9D=B4=EB=A6=84=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=97=90=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/message/ErrorCode.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/message/ErrorCode.java b/src/main/java/com/tiki/server/document/message/ErrorCode.java index c78424b2..3a310735 100644 --- a/src/main/java/com/tiki/server/document/message/ErrorCode.java +++ b/src/main/java/com/tiki/server/document/message/ErrorCode.java @@ -1,6 +1,7 @@ package com.tiki.server.document.message; import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.NOT_FOUND; @@ -20,7 +21,10 @@ public enum ErrorCode { INVALID_AUTHORIZATION(FORBIDDEN, "문서에 대한 권한이 없습니다."), /* 404 NOT_FOUND : 자원을 찾을 수 없음 */ - INVALID_DOCUMENT(NOT_FOUND, "유효하지 않은 문서입니다."); + INVALID_DOCUMENT(NOT_FOUND, "유효하지 않은 문서입니다."), + + /* 409 CONFLICT : 중복된 자원 */ + DOCUMENT_NAME_DUPLICATE(CONFLICT, "중복된 파일 이름입니다."); private final HttpStatus httpStatus; private final String message; From 1d57b96c8b94bb9815507a6d6dc7b44e91abe693 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:32:44 +0900 Subject: [PATCH 007/101] =?UTF-8?q?feat(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=9D=B4=EB=A6=84=20=EC=A4=91=EB=B3=B5=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 중복된 파일 이름이 존재한다면 예외 발생 --- .../document/service/DocumentService.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index d27f3446..be3c6e1e 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -1,5 +1,6 @@ package com.tiki.server.document.service; +import static com.tiki.server.document.message.ErrorCode.DOCUMENT_NAME_DUPLICATE; import static com.tiki.server.document.message.ErrorCode.INVALID_AUTHORIZATION; import java.util.List; @@ -54,10 +55,9 @@ public void deleteDocument(long memberId, long teamId, long documentId) { public DocumentsCreateResponse createDocuments(long memberId, long teamId, DocumentsCreateRequest request) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); validateFolder(request.folderId(), teamId); - List documents = documentFinder.findByTeamIdAndFolderId(teamId, request.folderId()); + validateFileName(request.folderId(), teamId, request); checkFolderIsExist(request.folderId()); List documentIds = request.documents().stream() - .filter(document -> checkFileNameIsNotDuplicated(document.fileName(), documents)) .map(document -> saveDocument(teamId, request.folderId(), document).getId()) .toList(); return DocumentsCreateResponse.from(documentIds); @@ -97,8 +97,16 @@ private Document saveDocument(long teamId, Long folderId, DocumentCreateRequest return documentSaver.save(document); } - private boolean checkFileNameIsNotDuplicated(final String fileName, final List documents) { - return documents.stream() - .noneMatch(document -> document.getFileName().equals(fileName)); + private void validateFileName(final Long folderId, final long teamId, final DocumentsCreateRequest request) { + List documents = documentFinder.findByTeamIdAndFolderId(teamId, folderId); + for (Document document : documents) { + checkFileNameIsDuplicated(document.getFileName(), request); + } + } + + private void checkFileNameIsDuplicated(final String fileName, final DocumentsCreateRequest request) { + if (request.documents().stream().anyMatch(document -> document.fileName().equals(fileName))) { + throw new DocumentException(DOCUMENT_NAME_DUPLICATE); + } } } From 0e0af792455ab00adf4783e83d93313ed8ba8ac4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:33:08 +0900 Subject: [PATCH 008/101] =?UTF-8?q?chore(DocumentService):=20=EB=AF=B8?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/service/DocumentService.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index be3c6e1e..fbbd4825 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -56,7 +56,6 @@ public DocumentsCreateResponse createDocuments(long memberId, long teamId, Docum memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); validateFolder(request.folderId(), teamId); validateFileName(request.folderId(), teamId, request); - checkFolderIsExist(request.folderId()); List documentIds = request.documents().stream() .map(document -> saveDocument(teamId, request.folderId(), document).getId()) .toList(); @@ -84,13 +83,6 @@ private void validateFolder(Long folderId, long teamId) { } } - private void checkFolderIsExist(Long folderId) { - if (folderId == null) { - return; - } - folderFinder.findById(folderId); - } - private Document saveDocument(long teamId, Long folderId, DocumentCreateRequest request) { Document document = Document.of( request.fileName(), request.fileUrl(), request.capacity(), teamId, folderId); From 18808786d45b07fe7bbd93e221bf3c8644290a61 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:34:31 +0900 Subject: [PATCH 009/101] =?UTF-8?q?feat(Folder):=20=ED=8C=80=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=EB=94=94=20=EA=B2=80=EC=A6=9D=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/entity/Folder.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/entity/Folder.java b/src/main/java/com/tiki/server/folder/entity/Folder.java index 21145e84..320344cb 100644 --- a/src/main/java/com/tiki/server/folder/entity/Folder.java +++ b/src/main/java/com/tiki/server/folder/entity/Folder.java @@ -1,8 +1,10 @@ package com.tiki.server.folder.entity; +import static com.tiki.server.document.message.ErrorCode.INVALID_AUTHORIZATION; import static jakarta.persistence.GenerationType.IDENTITY; import com.tiki.server.common.entity.BaseTime; +import com.tiki.server.document.exception.DocumentException; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -31,6 +33,12 @@ public Folder(String name, Folder parentFolder, long teamId) { this.teamId = teamId; } + public void validateTeamId(final long teamId) { + if (this.teamId != teamId) { + throw new DocumentException(INVALID_AUTHORIZATION); + } + } + private String generatePath(Folder parentFolder) { if (parentFolder == null) { return ""; From 35acb3cc1d8270884e151da53dd5ffb93855256b Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:35:13 +0900 Subject: [PATCH 010/101] =?UTF-8?q?refactor(DocumentService):=20=ED=8C=80?= =?UTF-8?q?=20=EC=95=84=EC=9D=B4=EB=94=94=20=EA=B2=80=EC=A6=9D=20=EC=B1=85?= =?UTF-8?q?=EC=9E=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/service/DocumentService.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index fbbd4825..b525aa24 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -1,7 +1,6 @@ package com.tiki.server.document.service; import static com.tiki.server.document.message.ErrorCode.DOCUMENT_NAME_DUPLICATE; -import static com.tiki.server.document.message.ErrorCode.INVALID_AUTHORIZATION; import java.util.List; @@ -78,9 +77,7 @@ private void validateFolder(Long folderId, long teamId) { return; } Folder folder = folderFinder.findById(folderId); - if (folder.getTeamId() != teamId) { - throw new DocumentException(INVALID_AUTHORIZATION); - } + folder.validateTeamId(teamId); } private Document saveDocument(long teamId, Long folderId, DocumentCreateRequest request) { From 2241f3f4477f577aab74b5e449b1b3d69b584b53 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:36:59 +0900 Subject: [PATCH 011/101] =?UTF-8?q?refactor(DocumentController):=20folderI?= =?UTF-8?q?d=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/controller/DocumentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index e26ced15..b9610d8a 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -65,7 +65,7 @@ public ResponseEntity> createDocuments( @RequestBody DocumentsCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); - DocumentsCreateResponse response = documentService.createDocuments(memberId, teamId, request); + DocumentsCreateResponse response = documentService.createDocuments(memberId, teamId, folderId, request); return ResponseEntity.created(UriGenerator.getUri("teams/" + teamId + "/documents")) .body(SuccessResponse.success(SUCCESS_CREATE_DOCUMENTS.getMessage(), response)); } From dec324a1b31e1f3eb32603adcc39b8b87ef55f28 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:37:20 +0900 Subject: [PATCH 012/101] =?UTF-8?q?refactor(DocumentService):=20folderId?= =?UTF-8?q?=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/service/DocumentService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index b525aa24..2fc9cadc 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -51,12 +51,13 @@ public void deleteDocument(long memberId, long teamId, long documentId) { } @Transactional - public DocumentsCreateResponse createDocuments(long memberId, long teamId, DocumentsCreateRequest request) { + public DocumentsCreateResponse createDocuments(final long memberId, final long teamId, + final Long folderId, final DocumentsCreateRequest request) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); - validateFolder(request.folderId(), teamId); - validateFileName(request.folderId(), teamId, request); + validateFolder(folderId, teamId); + validateFileName(folderId, teamId, request); List documentIds = request.documents().stream() - .map(document -> saveDocument(teamId, request.folderId(), document).getId()) + .map(document -> saveDocument(teamId, folderId, document).getId()) .toList(); return DocumentsCreateResponse.from(documentIds); } From 1601f99312eee54057910c66055104dce3a125be Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:41:45 +0900 Subject: [PATCH 013/101] =?UTF-8?q?refactor(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=95=84=EC=9D=B4=EB=94=94=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=83=9D=EC=84=B1=20=EB=A1=9C=EC=A7=81=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/service/DocumentService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 2fc9cadc..331e11bd 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -56,9 +56,7 @@ public DocumentsCreateResponse createDocuments(final long memberId, final long t memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); validateFolder(folderId, teamId); validateFileName(folderId, teamId, request); - List documentIds = request.documents().stream() - .map(document -> saveDocument(teamId, folderId, document).getId()) - .toList(); + List documentIds = saveDocuments(teamId, folderId, request); return DocumentsCreateResponse.from(documentIds); } @@ -81,6 +79,12 @@ private void validateFolder(Long folderId, long teamId) { folder.validateTeamId(teamId); } + private List saveDocuments(final long teamId, final Long folderId, final DocumentsCreateRequest request) { + return request.documents().stream() + .map(document -> saveDocument(teamId, folderId, document).getId()) + .toList(); + } + private Document saveDocument(long teamId, Long folderId, DocumentCreateRequest request) { Document document = Document.of( request.fileName(), request.fileUrl(), request.capacity(), teamId, folderId); From 6a57b011128a2bed38a0c1192ac31113a8f06993 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:42:16 +0900 Subject: [PATCH 014/101] =?UTF-8?q?style(DocumentService):=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EC=84=A0=EC=96=B8=20=EC=88=9C=EC=84=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/service/DocumentService.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 331e11bd..95d1b91d 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -79,18 +79,6 @@ private void validateFolder(Long folderId, long teamId) { folder.validateTeamId(teamId); } - private List saveDocuments(final long teamId, final Long folderId, final DocumentsCreateRequest request) { - return request.documents().stream() - .map(document -> saveDocument(teamId, folderId, document).getId()) - .toList(); - } - - private Document saveDocument(long teamId, Long folderId, DocumentCreateRequest request) { - Document document = Document.of( - request.fileName(), request.fileUrl(), request.capacity(), teamId, folderId); - return documentSaver.save(document); - } - private void validateFileName(final Long folderId, final long teamId, final DocumentsCreateRequest request) { List documents = documentFinder.findByTeamIdAndFolderId(teamId, folderId); for (Document document : documents) { @@ -103,4 +91,16 @@ private void checkFileNameIsDuplicated(final String fileName, final DocumentsCre throw new DocumentException(DOCUMENT_NAME_DUPLICATE); } } + + private List saveDocuments(final long teamId, final Long folderId, final DocumentsCreateRequest request) { + return request.documents().stream() + .map(document -> saveDocument(teamId, folderId, document).getId()) + .toList(); + } + + private Document saveDocument(long teamId, Long folderId, DocumentCreateRequest request) { + Document document = Document.of( + request.fileName(), request.fileUrl(), request.capacity(), teamId, folderId); + return documentSaver.save(document); + } } From 739d99d2f75e7d6817b96e4e946b823141efca69 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:44:56 +0900 Subject: [PATCH 015/101] =?UTF-8?q?refactor(DocumentsCreateRequest):=20?= =?UTF-8?q?=ED=8F=B4=EB=8D=94=20id=20=EC=9A=94=EC=B2=AD=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/document/dto/request/DocumentsCreateRequest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/document/dto/request/DocumentsCreateRequest.java b/src/main/java/com/tiki/server/document/dto/request/DocumentsCreateRequest.java index d417496f..91dcc8a8 100644 --- a/src/main/java/com/tiki/server/document/dto/request/DocumentsCreateRequest.java +++ b/src/main/java/com/tiki/server/document/dto/request/DocumentsCreateRequest.java @@ -3,7 +3,6 @@ import java.util.List; public record DocumentsCreateRequest( - List documents, - Long folderId + List documents ) { } From 728eccc7fbb48ae1e39baef16e5b1b48ee192e0e Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:51:43 +0900 Subject: [PATCH 016/101] =?UTF-8?q?refactor(FolderController):=20url=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit teamId와 folderId가 url에 드러나도록 수정 --- .../com/tiki/server/folder/controller/FolderController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index 0f70b546..7dfef98a 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -27,12 +27,12 @@ @RestController @RequiredArgsConstructor -@RequestMapping("api/v1/folders") +@RequestMapping("api/v1") public class FolderController { private final FolderService folderService; - @GetMapping() + @GetMapping("/teams/{teamId}/folders") public ResponseEntity> getFolders( final Principal principal, @RequestHeader("team-id") long teamId, @@ -43,7 +43,7 @@ public ResponseEntity> getFolders( return ResponseEntity.ok(success(SUCCESS_GET_FOLDERS.getMessage(), response)); } - @PostMapping() + @PostMapping("/teams/{teamId}/folders") public ResponseEntity> createFolder( Principal principal, @RequestHeader("team-id") long teamId, From 83d625c40b5c0378f460087a05d8abbc41282ade Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:52:19 +0900 Subject: [PATCH 017/101] =?UTF-8?q?style(DocumentController):=20=EB=AF=B8?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=20import=EB=AC=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/controller/DocumentController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index b9610d8a..0be55e51 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; From 1d93bdd70970da0580c478620e01fedc3e4706f9 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 15:57:14 +0900 Subject: [PATCH 018/101] =?UTF-8?q?refactor(FolderController):=20teamId=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/controller/FolderController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index 7dfef98a..47e91ca0 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -9,9 +9,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -35,7 +35,7 @@ public class FolderController { @GetMapping("/teams/{teamId}/folders") public ResponseEntity> getFolders( final Principal principal, - @RequestHeader("team-id") long teamId, + @PathVariable long teamId, @RequestParam(defaultValue = ROOT_PATH) String path ) { long memberId = Long.parseLong(principal.getName()); @@ -46,7 +46,7 @@ public ResponseEntity> getFolders( @PostMapping("/teams/{teamId}/folders") public ResponseEntity> createFolder( Principal principal, - @RequestHeader("team-id") long teamId, + @PathVariable long teamId, @RequestBody FolderCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); From 4d5671347b7ad3bf9caf004b2703febd5a14304c Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:01:48 +0900 Subject: [PATCH 019/101] =?UTF-8?q?refactor(FolderController):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20id=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/controller/FolderController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index 47e91ca0..e35bf28b 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -36,10 +36,11 @@ public class FolderController { public ResponseEntity> getFolders( final Principal principal, @PathVariable long teamId, + @RequestParam(required = false) Long folderId, @RequestParam(defaultValue = ROOT_PATH) String path ) { long memberId = Long.parseLong(principal.getName()); - FoldersGetResponse response = folderService.get(memberId, teamId, path); + FoldersGetResponse response = folderService.get(memberId, teamId, folderId, path); return ResponseEntity.ok(success(SUCCESS_GET_FOLDERS.getMessage(), response)); } @@ -47,10 +48,11 @@ public ResponseEntity> getFolders( public ResponseEntity> createFolder( Principal principal, @PathVariable long teamId, + @RequestParam(required = false) Long folderId, @RequestBody FolderCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); - FolderCreateResponse response = folderService.create(memberId, teamId, request); + FolderCreateResponse response = folderService.create(memberId, teamId, folderId, request); return ResponseEntity.created(UriGenerator.getUri("api/v1/folders/" + response.folderId())) .body(success(SUCCESS_CREATE_FOLDER.getMessage(), response)); } From 37c005a366426fa517b05af29804d6fa3320fc27 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:04:32 +0900 Subject: [PATCH 020/101] =?UTF-8?q?refactor(FolderService):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EC=B0=BE=EA=B8=B0=20=EC=8B=9C,=20=ED=8C=80=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=EB=94=94=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/folder/service/FolderService.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 8358976c..0509643b 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -24,25 +24,30 @@ public class FolderService { private final FolderSaver folderSaver; private final MemberTeamManagerFinder memberTeamManagerFinder; - public FoldersGetResponse get(final long memberId, final long teamId, final String path) { + public FoldersGetResponse get(final long memberId, final long teamId, + final Long folderId, final String path) { memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + Folder folder = getFolder(teamId, folderId); List folders = folderFinder.findByTeamIdAndPath(teamId, path); return FoldersGetResponse.from(folders); } @Transactional - public FolderCreateResponse create(long memberId, long teamId, FolderCreateRequest request) { + public FolderCreateResponse create(final long memberId, final long teamId, + final Long folderId, final FolderCreateRequest request) { // 같은 레벨 파일명 중복 방지 로직 추가 필요 memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); - Folder parentFolder = getFolder(request.parentId()); + Folder parentFolder = getFolder(teamId, request.parentId()); Folder folder = folderSaver.save(new Folder(request.name(), parentFolder, teamId)); return FolderCreateResponse.from(folder.getId()); } - private Folder getFolder(Long folderId) { + private Folder getFolder(final long teamId, final Long folderId) { if (folderId == null) { return null; } - return folderFinder.findById(folderId); + Folder folder = folderFinder.findById(folderId); + folder.validateTeamId(teamId); + return folder; } } From 933806530a8d02b2fdbb8587101d6a97591fbd2c Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:05:24 +0900 Subject: [PATCH 021/101] =?UTF-8?q?refactor(FolderController):=20url?= =?UTF-8?q?=EC=97=90=EC=84=9C=20path=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/controller/FolderController.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index e35bf28b..ca827830 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -36,11 +36,10 @@ public class FolderController { public ResponseEntity> getFolders( final Principal principal, @PathVariable long teamId, - @RequestParam(required = false) Long folderId, - @RequestParam(defaultValue = ROOT_PATH) String path + @RequestParam(required = false) Long folderId ) { long memberId = Long.parseLong(principal.getName()); - FoldersGetResponse response = folderService.get(memberId, teamId, folderId, path); + FoldersGetResponse response = folderService.get(memberId, teamId, folderId); return ResponseEntity.ok(success(SUCCESS_GET_FOLDERS.getMessage(), response)); } From 28400df2b95d7aa6a06824ba83f75f749ba02ed2 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:05:54 +0900 Subject: [PATCH 022/101] =?UTF-8?q?refactor(FolderService):=20path=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC=20=EB=B0=A9=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/service/FolderService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 0509643b..816e1de4 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -25,9 +25,10 @@ public class FolderService { private final MemberTeamManagerFinder memberTeamManagerFinder; public FoldersGetResponse get(final long memberId, final long teamId, - final Long folderId, final String path) { + final Long folderId) { memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); Folder folder = getFolder(teamId, folderId); + String path = folder.getPath(); List folders = folderFinder.findByTeamIdAndPath(teamId, path); return FoldersGetResponse.from(folders); } From b9561b433fcf19df8dd533101c777beb3c4c6b47 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:06:28 +0900 Subject: [PATCH 023/101] =?UTF-8?q?refactor(FolderCreateRequest):=20?= =?UTF-8?q?=EB=B6=80=EB=AA=A8=20=ED=8F=B4=EB=8D=94=20id=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/folder/dto/request/FolderCreateRequest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/dto/request/FolderCreateRequest.java b/src/main/java/com/tiki/server/folder/dto/request/FolderCreateRequest.java index af4aa4f8..799af52f 100644 --- a/src/main/java/com/tiki/server/folder/dto/request/FolderCreateRequest.java +++ b/src/main/java/com/tiki/server/folder/dto/request/FolderCreateRequest.java @@ -3,7 +3,6 @@ import lombok.NonNull; public record FolderCreateRequest( - @NonNull String name, - Long parentId + @NonNull String name ) { } From f52140399d65ac445b70146c928d06a41c67ba45 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:17:28 +0900 Subject: [PATCH 024/101] =?UTF-8?q?refactor(FolderService):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20path=20=EC=B6=94=EC=B6=9C=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/folder/service/FolderService.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 816e1de4..19343e52 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -1,5 +1,7 @@ package com.tiki.server.folder.service; +import static com.tiki.server.folder.constant.Constant.ROOT_PATH; + import java.util.List; import org.springframework.stereotype.Service; @@ -27,8 +29,7 @@ public class FolderService { public FoldersGetResponse get(final long memberId, final long teamId, final Long folderId) { memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - Folder folder = getFolder(teamId, folderId); - String path = folder.getPath(); + String path = getFolderPath(teamId, folderId); List folders = folderFinder.findByTeamIdAndPath(teamId, path); return FoldersGetResponse.from(folders); } @@ -51,4 +52,13 @@ private Folder getFolder(final long teamId, final Long folderId) { folder.validateTeamId(teamId); return folder; } + + private String getFolderPath(final long teamId, final Long folderId) { + if (folderId == null) { + return ROOT_PATH; + } + Folder folder = folderFinder.findById(folderId); + folder.validateTeamId(teamId); + return folder.getPath(); + } } From aa0600b1de05864042af6c589c79f4f5e10ae485 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:18:01 +0900 Subject: [PATCH 025/101] =?UTF-8?q?feat(Folder):=20=EC=9E=90=EC=8B=9D=20?= =?UTF-8?q?=ED=8F=B4=EB=8D=94=20path=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/entity/Folder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/entity/Folder.java b/src/main/java/com/tiki/server/folder/entity/Folder.java index 320344cb..c0c5b849 100644 --- a/src/main/java/com/tiki/server/folder/entity/Folder.java +++ b/src/main/java/com/tiki/server/folder/entity/Folder.java @@ -39,6 +39,10 @@ public void validateTeamId(final long teamId) { } } + public String getChildPath() { + return path + "/" + id; + } + private String generatePath(Folder parentFolder) { if (parentFolder == null) { return ""; From f50af724abf8f0940d3af576c1f04f42f1a83232 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:21:34 +0900 Subject: [PATCH 026/101] =?UTF-8?q?feat(ErrorCode):=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EB=90=9C=20=ED=8F=B4=EB=8D=94=20=EC=9D=B4=EB=A6=84=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=97=90=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/message/ErrorCode.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/message/ErrorCode.java b/src/main/java/com/tiki/server/folder/message/ErrorCode.java index 2ffa4988..57bd9afe 100644 --- a/src/main/java/com/tiki/server/folder/message/ErrorCode.java +++ b/src/main/java/com/tiki/server/folder/message/ErrorCode.java @@ -1,5 +1,6 @@ package com.tiki.server.folder.message; +import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.NOT_FOUND; import org.springframework.http.HttpStatus; @@ -12,7 +13,10 @@ public enum ErrorCode { /* 404 NOT_FOUND : 자원을 찾을 수 없음 */ - INVALID_FOLDER(NOT_FOUND, "유효하지 않은 폴더입니다."); + INVALID_FOLDER(NOT_FOUND, "유효하지 않은 폴더입니다."), + + /* 409 CONFLICT : 중복된 자원 */ + FOLDER_NAME_DUPLICATE(CONFLICT, "중복된 폴더 이름입니다.");; private final HttpStatus httpStatus; private final String message; From 1056a118695486e2ca97ce110babafcd208bb203 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:23:04 +0900 Subject: [PATCH 027/101] =?UTF-8?q?feat(FolderService):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EC=9D=B4=EB=A6=84=20=EC=A4=91=EB=B3=B5=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 중복된 폴더 이름이 존재한다면 예외 발생 --- .../tiki/server/folder/service/FolderService.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 19343e52..71670913 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -1,6 +1,7 @@ package com.tiki.server.folder.service; import static com.tiki.server.folder.constant.Constant.ROOT_PATH; +import static com.tiki.server.folder.message.ErrorCode.FOLDER_NAME_DUPLICATE; import java.util.List; @@ -13,6 +14,7 @@ import com.tiki.server.folder.dto.response.FolderCreateResponse; import com.tiki.server.folder.dto.response.FoldersGetResponse; import com.tiki.server.folder.entity.Folder; +import com.tiki.server.folder.exception.FolderException; import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; import lombok.RequiredArgsConstructor; @@ -37,9 +39,10 @@ public FoldersGetResponse get(final long memberId, final long teamId, @Transactional public FolderCreateResponse create(final long memberId, final long teamId, final Long folderId, final FolderCreateRequest request) { - // 같은 레벨 파일명 중복 방지 로직 추가 필요 memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); - Folder parentFolder = getFolder(teamId, request.parentId()); + Folder parentFolder = getFolder(teamId, folderId); + String path = parentFolder.getChildPath(); + validateFolderName(teamId, path, request); Folder folder = folderSaver.save(new Folder(request.name(), parentFolder, teamId)); return FolderCreateResponse.from(folder.getId()); } @@ -61,4 +64,11 @@ private String getFolderPath(final long teamId, final Long folderId) { folder.validateTeamId(teamId); return folder.getPath(); } + + private void validateFolderName(final long teamId, final String path, final FolderCreateRequest request) { + List folders = folderFinder.findByTeamIdAndPath(teamId, path); + if (folders.stream().anyMatch(folder -> folder.getName().equals(request.name()))) { + throw new FolderException(FOLDER_NAME_DUPLICATE); + } + } } From af6c18dff4650b16408ffc6b13b80246879499ce Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:40:23 +0900 Subject: [PATCH 028/101] =?UTF-8?q?feat(ErrorHandler):=20FolderException?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/common/handler/ErrorHandler.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/tiki/server/common/handler/ErrorHandler.java b/src/main/java/com/tiki/server/common/handler/ErrorHandler.java index 5b7b29f1..a5285f53 100644 --- a/src/main/java/com/tiki/server/common/handler/ErrorHandler.java +++ b/src/main/java/com/tiki/server/common/handler/ErrorHandler.java @@ -3,6 +3,7 @@ import com.tiki.server.auth.exception.AuthException; import com.tiki.server.common.dto.ErrorCodeResponse; import com.tiki.server.emailverification.exception.EmailVerificationException; +import com.tiki.server.folder.exception.FolderException; import com.tiki.server.note.exception.NoteException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -85,6 +86,13 @@ public ResponseEntity MailException(EmailVerificationException exc return ResponseEntity.status(errorCode.getHttpStatus()).body(ErrorResponse.of(errorCode.getMessage())); } + @ExceptionHandler(FolderException.class) + public ResponseEntity folderException(FolderException exception) { + log.error(exception.getMessage()); + val errorCode = exception.getErrorCode(); + return ResponseEntity.status(errorCode.getHttpStatus()).body(ErrorResponse.of(errorCode.getMessage())); + } + @ExceptionHandler(AuthException.class) public ResponseEntity AuthException(AuthException exception) { log.error(exception.getMessage()); From 8e7e44cc30b474ad034aaad3fc9f8518ea669a16 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:40:50 +0900 Subject: [PATCH 029/101] =?UTF-8?q?chore(ErrorHandler):=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 대문자 시작 메소드 소문자로 수정 --- .../java/com/tiki/server/common/handler/ErrorHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/common/handler/ErrorHandler.java b/src/main/java/com/tiki/server/common/handler/ErrorHandler.java index a5285f53..d86ae5d7 100644 --- a/src/main/java/com/tiki/server/common/handler/ErrorHandler.java +++ b/src/main/java/com/tiki/server/common/handler/ErrorHandler.java @@ -80,7 +80,7 @@ public ResponseEntity externalException(ExternalException exceptio } @ExceptionHandler(EmailVerificationException.class) - public ResponseEntity MailException(EmailVerificationException exception) { + public ResponseEntity mailException(EmailVerificationException exception) { log.error(exception.getMessage()); val errorCode = exception.getErrorCode(); return ResponseEntity.status(errorCode.getHttpStatus()).body(ErrorResponse.of(errorCode.getMessage())); @@ -94,7 +94,7 @@ public ResponseEntity folderException(FolderException exception) { } @ExceptionHandler(AuthException.class) - public ResponseEntity AuthException(AuthException exception) { + public ResponseEntity authException(AuthException exception) { log.error(exception.getMessage()); val errorCode = exception.getErrorCode(); return ResponseEntity.status(errorCode.getHttpStatus()).body( @@ -109,7 +109,7 @@ public ResponseEntity httpMessageNotReadableException(HttpMessageN } @ExceptionHandler(Exception.class) - public ResponseEntity Exception(Exception exception) { + public ResponseEntity exception(Exception exception) { log.error(exception.getMessage()); val errorCode = UNCAUGHT_SERVER_EXCEPTION; return ResponseEntity.status(errorCode.getHttpStatus()).body(ErrorResponse.of(errorCode.getMessage())); From 6bab42d3e8aedff46f55ee644e2fccb847faf3e7 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:41:21 +0900 Subject: [PATCH 030/101] =?UTF-8?q?fix(FolderService):=20=EC=9E=90?= =?UTF-8?q?=EC=8B=9D=20=EC=A3=BC=EC=86=8C=EB=A5=BC=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/service/FolderService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 71670913..942f1e98 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -41,7 +41,7 @@ public FolderCreateResponse create(final long memberId, final long teamId, final Long folderId, final FolderCreateRequest request) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); Folder parentFolder = getFolder(teamId, folderId); - String path = parentFolder.getChildPath(); + String path = getFolderPath(teamId, folderId); validateFolderName(teamId, path, request); Folder folder = folderSaver.save(new Folder(request.name(), parentFolder, teamId)); return FolderCreateResponse.from(folder.getId()); @@ -62,7 +62,7 @@ private String getFolderPath(final long teamId, final Long folderId) { } Folder folder = folderFinder.findById(folderId); folder.validateTeamId(teamId); - return folder.getPath(); + return folder.getChildPath(); } private void validateFolderName(final long teamId, final String path, final FolderCreateRequest request) { From 45d23c32eb05395cbd895744b945475764225e95 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:43:43 +0900 Subject: [PATCH 031/101] =?UTF-8?q?feat(Constant):=20=EA=B5=AC=EB=B6=84?= =?UTF-8?q?=EC=9E=90=20=EC=83=81=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/constant/Constant.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/tiki/server/folder/constant/Constant.java b/src/main/java/com/tiki/server/folder/constant/Constant.java index c6b2f0a9..e3f536e5 100644 --- a/src/main/java/com/tiki/server/folder/constant/Constant.java +++ b/src/main/java/com/tiki/server/folder/constant/Constant.java @@ -3,4 +3,5 @@ public class Constant { public static final String ROOT_PATH = ""; + public static final String SEPARATOR = "/"; } From c9c53db4a9a5263b1c00ef2786ec97f291c1416a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:44:15 +0900 Subject: [PATCH 032/101] =?UTF-8?q?refactor(Folder):=20=EC=83=81=EC=88=98?= =?UTF-8?q?=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/entity/Folder.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/entity/Folder.java b/src/main/java/com/tiki/server/folder/entity/Folder.java index c0c5b849..162bffd8 100644 --- a/src/main/java/com/tiki/server/folder/entity/Folder.java +++ b/src/main/java/com/tiki/server/folder/entity/Folder.java @@ -1,6 +1,8 @@ package com.tiki.server.folder.entity; import static com.tiki.server.document.message.ErrorCode.INVALID_AUTHORIZATION; +import static com.tiki.server.folder.constant.Constant.ROOT_PATH; +import static com.tiki.server.folder.constant.Constant.SEPARATOR; import static jakarta.persistence.GenerationType.IDENTITY; import com.tiki.server.common.entity.BaseTime; @@ -40,13 +42,13 @@ public void validateTeamId(final long teamId) { } public String getChildPath() { - return path + "/" + id; + return path + SEPARATOR + id; } private String generatePath(Folder parentFolder) { if (parentFolder == null) { - return ""; + return ROOT_PATH; } - return parentFolder.getPath() + "/" + parentFolder.getId(); + return parentFolder.getPath() + SEPARATOR + parentFolder.getId(); } } From 1f2c80fbc5a40d584f5168499240cd2cbae749a4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:45:40 +0900 Subject: [PATCH 033/101] =?UTF-8?q?refactor(FolderService):=20getFolder,?= =?UTF-8?q?=20getFolderPath=20=EC=A4=91=EB=B3=B5=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/service/FolderService.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 942f1e98..41ce2234 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -31,7 +31,8 @@ public class FolderService { public FoldersGetResponse get(final long memberId, final long teamId, final Long folderId) { memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - String path = getFolderPath(teamId, folderId); + Folder folder = getFolder(teamId, folderId); + String path = getFolderPath(folder); List folders = folderFinder.findByTeamIdAndPath(teamId, path); return FoldersGetResponse.from(folders); } @@ -41,7 +42,7 @@ public FolderCreateResponse create(final long memberId, final long teamId, final Long folderId, final FolderCreateRequest request) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); Folder parentFolder = getFolder(teamId, folderId); - String path = getFolderPath(teamId, folderId); + String path = getFolderPath(parentFolder); validateFolderName(teamId, path, request); Folder folder = folderSaver.save(new Folder(request.name(), parentFolder, teamId)); return FolderCreateResponse.from(folder.getId()); @@ -56,12 +57,10 @@ private Folder getFolder(final long teamId, final Long folderId) { return folder; } - private String getFolderPath(final long teamId, final Long folderId) { - if (folderId == null) { + private String getFolderPath(final Folder folder) { + if (folder == null) { return ROOT_PATH; } - Folder folder = folderFinder.findById(folderId); - folder.validateTeamId(teamId); return folder.getChildPath(); } From c1d186c2cfaaadd64ddeb37b559ed026f5c0ffbb Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:46:05 +0900 Subject: [PATCH 034/101] =?UTF-8?q?refactor(FolderService):=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getFolderPath -> getChildFolderPath으로 수정 --- .../java/com/tiki/server/folder/service/FolderService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 41ce2234..d3ce716e 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -32,7 +32,7 @@ public FoldersGetResponse get(final long memberId, final long teamId, final Long folderId) { memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); Folder folder = getFolder(teamId, folderId); - String path = getFolderPath(folder); + String path = getChildFolderPath(folder); List folders = folderFinder.findByTeamIdAndPath(teamId, path); return FoldersGetResponse.from(folders); } @@ -42,7 +42,7 @@ public FolderCreateResponse create(final long memberId, final long teamId, final Long folderId, final FolderCreateRequest request) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); Folder parentFolder = getFolder(teamId, folderId); - String path = getFolderPath(parentFolder); + String path = getChildFolderPath(parentFolder); validateFolderName(teamId, path, request); Folder folder = folderSaver.save(new Folder(request.name(), parentFolder, teamId)); return FolderCreateResponse.from(folder.getId()); @@ -57,7 +57,7 @@ private Folder getFolder(final long teamId, final Long folderId) { return folder; } - private String getFolderPath(final Folder folder) { + private String getChildFolderPath(final Folder folder) { if (folder == null) { return ROOT_PATH; } From 9423c57571e08ce18cda438c9be8ee3b851951aa Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:48:19 +0900 Subject: [PATCH 035/101] =?UTF-8?q?refactor(DocumentController):=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/controller/DocumentController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index 0be55e51..cc4f71be 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -57,16 +57,16 @@ public ResponseEntity deleteDocument( } @PostMapping("/teams/{teamId}/documents") - public ResponseEntity> createDocuments( + public ResponseEntity> createDocuments( Principal principal, @PathVariable long teamId, @RequestParam(required = false) Long folderId, @RequestBody DocumentsCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); - DocumentsCreateResponse response = documentService.createDocuments(memberId, teamId, folderId, request); + documentService.createDocuments(memberId, teamId, folderId, request); return ResponseEntity.created(UriGenerator.getUri("teams/" + teamId + "/documents")) - .body(SuccessResponse.success(SUCCESS_CREATE_DOCUMENTS.getMessage(), response)); + .body(SuccessResponse.success(SUCCESS_CREATE_DOCUMENTS.getMessage())); } @GetMapping("/teams/{teamId}/documents") From a67e400a5203d0ebf035853a8438e09f254fefe8 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 19 Nov 2024 16:50:18 +0900 Subject: [PATCH 036/101] =?UTF-8?q?refactor(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/document/service/DocumentService.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 95d1b91d..cae6a76f 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -51,13 +51,12 @@ public void deleteDocument(long memberId, long teamId, long documentId) { } @Transactional - public DocumentsCreateResponse createDocuments(final long memberId, final long teamId, + public void createDocuments(final long memberId, final long teamId, final Long folderId, final DocumentsCreateRequest request) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); validateFolder(folderId, teamId); validateFileName(folderId, teamId, request); - List documentIds = saveDocuments(teamId, folderId, request); - return DocumentsCreateResponse.from(documentIds); + saveDocuments(teamId, folderId, request); } public DocumentsGetResponse get(final long memberId, final long teamId, final Long folderId) { @@ -92,15 +91,13 @@ private void checkFileNameIsDuplicated(final String fileName, final DocumentsCre } } - private List saveDocuments(final long teamId, final Long folderId, final DocumentsCreateRequest request) { - return request.documents().stream() - .map(document -> saveDocument(teamId, folderId, document).getId()) - .toList(); + private void saveDocuments(final long teamId, final Long folderId, final DocumentsCreateRequest request) { + request.documents().forEach(document -> saveDocument(teamId, folderId, document)); } - private Document saveDocument(long teamId, Long folderId, DocumentCreateRequest request) { + private void saveDocument(long teamId, Long folderId, DocumentCreateRequest request) { Document document = Document.of( request.fileName(), request.fileUrl(), request.capacity(), teamId, folderId); - return documentSaver.save(document); + documentSaver.save(document); } } From f2b413ee4d824dcc575bf5c3367d3fe94d2ed904 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 20 Nov 2024 14:07:24 +0900 Subject: [PATCH 037/101] =?UTF-8?q?chore(FolderService):=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/service/FolderService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index d3ce716e..21f27a77 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -30,7 +30,7 @@ public class FolderService { public FoldersGetResponse get(final long memberId, final long teamId, final Long folderId) { - memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); Folder folder = getFolder(teamId, folderId); String path = getChildFolderPath(folder); List folders = folderFinder.findByTeamIdAndPath(teamId, path); From 3b0331890ad05c961c9df6113655256e148b351a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 20 Nov 2024 14:07:39 +0900 Subject: [PATCH 038/101] =?UTF-8?q?chore(DocumentService):=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/service/DocumentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index cae6a76f..23261d16 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -60,7 +60,7 @@ public void createDocuments(final long memberId, final long teamId, } public DocumentsGetResponse get(final long memberId, final long teamId, final Long folderId) { - memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); List documents = documentFinder.findByTeamIdAndFolderId(teamId, folderId); return DocumentsGetResponse.from(documents); } From 9a0cf94150bb7ec9b29e8a730b803924154ebcdf Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 20 Nov 2024 14:09:33 +0900 Subject: [PATCH 039/101] =?UTF-8?q?chore(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/service/DocumentService.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 23261d16..0f2271ab 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -13,7 +13,6 @@ import com.tiki.server.document.adapter.DocumentSaver; import com.tiki.server.document.dto.request.DocumentCreateRequest; import com.tiki.server.document.dto.request.DocumentsCreateRequest; -import com.tiki.server.document.dto.response.DocumentsCreateResponse; import com.tiki.server.document.dto.response.DocumentsGetResponse; import com.tiki.server.document.entity.Document; import com.tiki.server.document.exception.DocumentException; @@ -35,7 +34,7 @@ public class DocumentService { private final FolderFinder folderFinder; private final MemberTeamManagerFinder memberTeamManagerFinder; - public DocumentsGetResponse getAllDocuments(long memberId, long teamId, String type) { + public DocumentsGetResponse getAllDocuments(final long memberId, final long teamId, final String type) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); Position accessiblePosition = Position.getAccessiblePosition(type); memberTeamManager.checkMemberAccessible(accessiblePosition); @@ -43,7 +42,7 @@ public DocumentsGetResponse getAllDocuments(long memberId, long teamId, String t } @Transactional - public void deleteDocument(long memberId, long teamId, long documentId) { + public void deleteDocument(final long memberId, final long teamId, final long documentId) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); Document document = documentFinder.findByIdWithTimeBlock(documentId); memberTeamManager.checkMemberAccessible(document.getTimeBlock().getAccessiblePosition()); @@ -65,12 +64,12 @@ public DocumentsGetResponse get(final long memberId, final long teamId, final Lo return DocumentsGetResponse.from(documents); } - private DocumentsGetResponse getAllDocumentsByType(long teamId, Position accessiblePosition) { + private DocumentsGetResponse getAllDocumentsByType(final long teamId, final Position accessiblePosition) { List documents = documentFinder.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); return DocumentsGetResponse.from(documents); } - private void validateFolder(Long folderId, long teamId) { + private void validateFolder(final Long folderId, final long teamId) { if (folderId == null) { return; } @@ -95,7 +94,7 @@ private void saveDocuments(final long teamId, final Long folderId, final Documen request.documents().forEach(document -> saveDocument(teamId, folderId, document)); } - private void saveDocument(long teamId, Long folderId, DocumentCreateRequest request) { + private void saveDocument(final long teamId, final Long folderId, final DocumentCreateRequest request) { Document document = Document.of( request.fileName(), request.fileUrl(), request.capacity(), teamId, folderId); documentSaver.save(document); From 256e0d9d4c1596ef2dbe8c753be2d18cb5f538cc Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 20 Nov 2024 14:10:12 +0900 Subject: [PATCH 040/101] =?UTF-8?q?chore(Folder):=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C=EB=93=9C=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/entity/Folder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/entity/Folder.java b/src/main/java/com/tiki/server/folder/entity/Folder.java index 162bffd8..b7f35a1a 100644 --- a/src/main/java/com/tiki/server/folder/entity/Folder.java +++ b/src/main/java/com/tiki/server/folder/entity/Folder.java @@ -29,7 +29,7 @@ public class Folder extends BaseTime { private long teamId; - public Folder(String name, Folder parentFolder, long teamId) { + public Folder(final String name, final Folder parentFolder, final long teamId) { this.name = name; this.path = generatePath(parentFolder); this.teamId = teamId; @@ -45,7 +45,7 @@ public String getChildPath() { return path + SEPARATOR + id; } - private String generatePath(Folder parentFolder) { + private String generatePath(final Folder parentFolder) { if (parentFolder == null) { return ROOT_PATH; } From 357b0db4d9fec8bd7fcbe91cad711b4e822addf8 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 20 Nov 2024 14:23:54 +0900 Subject: [PATCH 041/101] =?UTF-8?q?chore(DocumentController):=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DocumentController.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index cc4f71be..20e0a09c 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -35,9 +35,9 @@ public class DocumentController implements DocumentControllerDocs { @Override @GetMapping("/documents/team/{teamId}/timeline") public ResponseEntity> getAllDocuments( - Principal principal, - @PathVariable long teamId, - @RequestParam String type + final Principal principal, + @PathVariable final long teamId, + @RequestParam final String type ) { long memberId = Long.parseLong(principal.getName()); DocumentsGetResponse response = documentService.getAllDocuments(memberId, teamId, type); @@ -47,9 +47,9 @@ public ResponseEntity> getAllDocuments( @Override @DeleteMapping("/documents/team/{teamId}/document/{documentId}") public ResponseEntity deleteDocument( - Principal principal, - @PathVariable long teamId, - @PathVariable long documentId + final Principal principal, + @PathVariable final long teamId, + @PathVariable final long documentId ) { long memberId = Long.parseLong(principal.getName()); documentService.deleteDocument(memberId, teamId, documentId); @@ -58,10 +58,10 @@ public ResponseEntity deleteDocument( @PostMapping("/teams/{teamId}/documents") public ResponseEntity> createDocuments( - Principal principal, - @PathVariable long teamId, - @RequestParam(required = false) Long folderId, - @RequestBody DocumentsCreateRequest request + final Principal principal, + @PathVariable final long teamId, + @RequestParam(required = false) final Long folderId, + @RequestBody final DocumentsCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); documentService.createDocuments(memberId, teamId, folderId, request); @@ -72,8 +72,8 @@ public ResponseEntity> createDocuments( @GetMapping("/teams/{teamId}/documents") public ResponseEntity> getDocuments( final Principal principal, - @PathVariable long teamId, - @RequestParam(required = false) Long folderId + @PathVariable final long teamId, + @RequestParam(required = false) final Long folderId ) { long memberId = Long.parseLong(principal.getName()); DocumentsGetResponse response = documentService.get(memberId, teamId, folderId); From 249d1889b02b917cf906017b38945d04945f493f Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 20 Nov 2024 15:19:06 +0900 Subject: [PATCH 042/101] =?UTF-8?q?chore(FolderController):=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/folder/controller/FolderController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index ca827830..9c8602ff 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -35,8 +35,8 @@ public class FolderController { @GetMapping("/teams/{teamId}/folders") public ResponseEntity> getFolders( final Principal principal, - @PathVariable long teamId, - @RequestParam(required = false) Long folderId + @PathVariable final long teamId, + @RequestParam(required = false) final Long folderId ) { long memberId = Long.parseLong(principal.getName()); FoldersGetResponse response = folderService.get(memberId, teamId, folderId); @@ -46,9 +46,9 @@ public ResponseEntity> getFolders( @PostMapping("/teams/{teamId}/folders") public ResponseEntity> createFolder( Principal principal, - @PathVariable long teamId, - @RequestParam(required = false) Long folderId, - @RequestBody FolderCreateRequest request + @PathVariable final long teamId, + @RequestParam(required = false) final Long folderId, + @RequestBody final FolderCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); FolderCreateResponse response = folderService.create(memberId, teamId, folderId, request); From a0f350ac512ac81d669f2522373e66b0990f845e Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 20 Nov 2024 15:19:46 +0900 Subject: [PATCH 043/101] =?UTF-8?q?chore(FolderFinder):=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/adapter/FolderFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java index d74576ae..698cd55b 100644 --- a/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java +++ b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java @@ -18,7 +18,7 @@ public class FolderFinder { private final FolderRepository folderRepository; - public Folder findById(long id) { + public Folder findById(final long id) { return folderRepository.findById(id) .orElseThrow(() -> new FolderException(INVALID_FOLDER)); } From d6a2eb8008facedb53c6390572ac71b069b1e1a1 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 20 Nov 2024 15:20:09 +0900 Subject: [PATCH 044/101] =?UTF-8?q?chore(FolderSaver):=20=ED=8C=8C?= =?UTF-8?q?=EB=A6=AC=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/adapter/FolderSaver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java b/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java index c00db2b5..f2a6b28b 100644 --- a/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java +++ b/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java @@ -12,7 +12,7 @@ public class FolderSaver { private final FolderRepository folderRepository; - public Folder save(Folder folder) { + public Folder save(final Folder folder) { return folderRepository.save(folder); } } From 784f08caa39227f8c3308ca8a10423ff841f2572 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 17:34:19 +0900 Subject: [PATCH 045/101] =?UTF-8?q?feat(DocumentFinder):=20=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문서 아이디 리스트로 문서 리스트 조회 --- .../com/tiki/server/document/adapter/DocumentFinder.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java index 451155dd..7b179925 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -21,6 +21,12 @@ public class DocumentFinder { private final DocumentRepository documentRepository; + public List findAllById(final List documentIds) { + return documentIds.stream() + .map(this::findByIdOrElseThrow) + .toList(); + } + public Document findByIdOrElseThrow(final long documentId) { return documentRepository.findById(documentId).orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); } From ff4b1fb8d24d7d8d744cd8db2afdbc12bf60d452 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 17:34:45 +0900 Subject: [PATCH 046/101] =?UTF-8?q?style(DocumentFinder):=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20import=EB=AC=B8=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/adapter/DocumentFinder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java index 7b179925..4a24e1c9 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -1,7 +1,6 @@ package com.tiki.server.document.adapter; import static com.tiki.server.document.message.ErrorCode.INVALID_DOCUMENT; -import static com.tiki.server.folder.constant.Constant.ROOT_PATH; import java.util.List; import java.util.Objects; From 893ee1b61e2715b25052398a6c98eef1cf87db30 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 17:36:32 +0900 Subject: [PATCH 047/101] =?UTF-8?q?refactor(DeletedDocument):=20=ED=83=80?= =?UTF-8?q?=EC=9E=84=20=EB=B8=94=EB=A1=9D=20=EC=BB=AC=EB=9F=BC=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/entity/DeletedDocument.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java index dcf7da07..ab287926 100644 --- a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java +++ b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java @@ -26,17 +26,13 @@ public class DeletedDocument { private String fileUrl; - @Column(name = "block_id") - private long timeBlockId; - private LocalDate deletedDate; @Builder - public static DeletedDocument of(String fileName, String fileUrl, long timeBlockId, LocalDate deletedDate) { + public static DeletedDocument of(String fileName, String fileUrl, LocalDate deletedDate) { return DeletedDocument.builder() .fileName(fileName) .fileUrl(fileUrl) - .timeBlockId(timeBlockId) .deletedDate(deletedDate) .build(); } From ef4cae7197b56c6cf9b0a0a2e3addefcfe175e4a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 17:38:04 +0900 Subject: [PATCH 048/101] =?UTF-8?q?feat(DeletedDocument):=20=EC=8B=A0?= =?UTF-8?q?=EA=B7=9C=20=EC=BB=AC=EB=9F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 팀 아이디 및 용량 데이터 추가 --- .../com/tiki/server/document/entity/DeletedDocument.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java index ab287926..dc5b628e 100644 --- a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java +++ b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java @@ -26,13 +26,19 @@ public class DeletedDocument { private String fileUrl; + private long teamId; + + private double capacity; + private LocalDate deletedDate; @Builder - public static DeletedDocument of(String fileName, String fileUrl, LocalDate deletedDate) { + public static DeletedDocument of(String fileName, String fileUrl, long teamId, double capacity, LocalDate deletedDate) { return DeletedDocument.builder() .fileName(fileName) .fileUrl(fileUrl) + .teamId(teamId) + .capacity(capacity) .deletedDate(deletedDate) .build(); } From 53fdcd8d3e1df035f48ed59cd1d28833c6ceeda0 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 17:38:56 +0900 Subject: [PATCH 049/101] =?UTF-8?q?chore(DeletedDocument):=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/entity/DeletedDocument.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java index dc5b628e..56527e41 100644 --- a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java +++ b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java @@ -33,7 +33,8 @@ public class DeletedDocument { private LocalDate deletedDate; @Builder - public static DeletedDocument of(String fileName, String fileUrl, long teamId, double capacity, LocalDate deletedDate) { + public static DeletedDocument of(final String fileName, final String fileUrl, final long teamId, + final double capacity, final LocalDate deletedDate) { return DeletedDocument.builder() .fileName(fileName) .fileUrl(fileUrl) From e645b01299e2d4f003cb8e7cc54e34b4a346979b Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 17:39:50 +0900 Subject: [PATCH 050/101] =?UTF-8?q?refactor(DeletedDocument):=20BaseTime?= =?UTF-8?q?=20=EC=83=81=EC=86=8D=20=EB=B0=8F=20deletedDate=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/entity/DeletedDocument.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java index 56527e41..eec8f533 100644 --- a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java +++ b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java @@ -4,6 +4,8 @@ import java.time.LocalDate; +import com.tiki.server.common.entity.BaseTime; + import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -15,7 +17,7 @@ @Entity @Getter @NoArgsConstructor -public class DeletedDocument { +public class DeletedDocument extends BaseTime { @Id @GeneratedValue(strategy = IDENTITY) @@ -30,17 +32,14 @@ public class DeletedDocument { private double capacity; - private LocalDate deletedDate; - @Builder public static DeletedDocument of(final String fileName, final String fileUrl, final long teamId, - final double capacity, final LocalDate deletedDate) { + final double capacity) { return DeletedDocument.builder() .fileName(fileName) .fileUrl(fileUrl) .teamId(teamId) .capacity(capacity) - .deletedDate(deletedDate) .build(); } } From 14f4050cc686f9de68e7f44ea252a4b8bd47f71e Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 18:16:38 +0900 Subject: [PATCH 051/101] =?UTF-8?q?feat(DeletedDocumentRepository):=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=ED=8C=8C=EC=9D=BC=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/repository/DeletedDocumentRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java diff --git a/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java b/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java new file mode 100644 index 00000000..f4595a5a --- /dev/null +++ b/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java @@ -0,0 +1,8 @@ +package com.tiki.server.document.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.tiki.server.document.entity.DeletedDocument; + +public interface DeletedDocumentRepository extends JpaRepository { +} From f8b6917b3bb2084414d4e91631f6983e40e8e0e7 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 18:17:05 +0900 Subject: [PATCH 052/101] =?UTF-8?q?feat(DeletedDocumentAdapter):=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=ED=8C=8C=EC=9D=BC=20=EC=96=B4=EB=8C=91?= =?UTF-8?q?=ED=84=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/DeletedDocumentAdapter.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java diff --git a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java new file mode 100644 index 00000000..39c685c7 --- /dev/null +++ b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java @@ -0,0 +1,25 @@ +package com.tiki.server.document.adapter; + +import java.util.List; + +import com.tiki.server.common.support.RepositoryAdapter; +import com.tiki.server.document.entity.DeletedDocument; +import com.tiki.server.document.entity.Document; +import com.tiki.server.document.repository.DeletedDocumentRepository; + +import lombok.RequiredArgsConstructor; + +@RepositoryAdapter +@RequiredArgsConstructor +public class DeletedDocumentAdapter { + + private final DeletedDocumentRepository deletedDocumentRepository; + + public void save(final List documents, final long teamId) { + documents.forEach(document -> deletedDocumentRepository.save(create(document, teamId))); + } + + private DeletedDocument create(final Document document, final long teamId) { + return DeletedDocument.of(document.getFileName(), document.getFileUrl(), teamId, document.getCapacity()); + } +} From 1c03ba39d1a88fbeaab3fe07b7bb483dfc2aa637 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 18:17:24 +0900 Subject: [PATCH 053/101] =?UTF-8?q?feat(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=9C=B4=EC=A7=80=ED=86=B5=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/service/DocumentService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 0f2271ab..767da79e 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -8,6 +8,7 @@ import org.springframework.transaction.annotation.Transactional; import com.tiki.server.common.entity.Position; +import com.tiki.server.document.adapter.DeletedDocumentAdapter; import com.tiki.server.document.adapter.DocumentDeleter; import com.tiki.server.document.adapter.DocumentFinder; import com.tiki.server.document.adapter.DocumentSaver; @@ -33,6 +34,7 @@ public class DocumentService { private final DocumentDeleter documentDeleter; private final FolderFinder folderFinder; private final MemberTeamManagerFinder memberTeamManagerFinder; + private final DeletedDocumentAdapter deletedDocumentAdapter; public DocumentsGetResponse getAllDocuments(final long memberId, final long teamId, final String type) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); @@ -64,6 +66,14 @@ public DocumentsGetResponse get(final long memberId, final long teamId, final Lo return DocumentsGetResponse.from(documents); } + @Transactional + public void delete(final long memberId, final long teamId, final List documentIds) { + memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); + List documents = documentFinder.findAllById(documentIds); + deletedDocumentAdapter.save(documents, teamId); + documentDeleter.deleteAll(documents); + } + private DocumentsGetResponse getAllDocumentsByType(final long teamId, final Position accessiblePosition) { List documents = documentFinder.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); return DocumentsGetResponse.from(documents); From 7bad5352f46bf117821d33e43851dfed65b46549 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 18:17:39 +0900 Subject: [PATCH 054/101] =?UTF-8?q?feat(DocumentController):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=9C=B4=EC=A7=80=ED=86=B5=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/controller/DocumentController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index 20e0a09c..28aecb58 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -4,6 +4,7 @@ import static com.tiki.server.document.message.SuccessMessage.SUCCESS_GET_DOCUMENTS; import java.security.Principal; +import java.util.List; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -79,4 +80,15 @@ public ResponseEntity> getDocuments( DocumentsGetResponse response = documentService.get(memberId, teamId, folderId); return ResponseEntity.ok(SuccessResponse.success(SUCCESS_GET_DOCUMENTS.getMessage(), response)); } + + @DeleteMapping("/teams/{teamId}/documents") + public ResponseEntity delete( + final Principal principal, + @PathVariable final long teamId, + @RequestParam final List documentIds + ) { + long memberId = Long.parseLong(principal.getName()); + documentService.delete(memberId, teamId, documentIds); + return ResponseEntity.noContent().build(); + } } From 1b4c32d8974ba77864e91e700a321d4bb324752a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 18:17:58 +0900 Subject: [PATCH 055/101] =?UTF-8?q?fix(DeletedDocument):=20stackoverflow?= =?UTF-8?q?=20=EB=B0=9C=EC=83=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/entity/DeletedDocument.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java index eec8f533..ff6bc1b8 100644 --- a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java +++ b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java @@ -1,6 +1,8 @@ package com.tiki.server.document.entity; import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PRIVATE; +import static lombok.AccessLevel.PROTECTED; import java.time.LocalDate; @@ -10,13 +12,16 @@ import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Entity @Getter -@NoArgsConstructor +@NoArgsConstructor(access = PROTECTED) +@Builder(access = PRIVATE) +@AllArgsConstructor(access = PRIVATE) public class DeletedDocument extends BaseTime { @Id @@ -32,7 +37,6 @@ public class DeletedDocument extends BaseTime { private double capacity; - @Builder public static DeletedDocument of(final String fileName, final String fileUrl, final long teamId, final double capacity) { return DeletedDocument.builder() From 6812c8b43dbcf5a4b0e5da9828dbf848707259dc Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 18:18:16 +0900 Subject: [PATCH 056/101] =?UTF-8?q?style(DeletedDocument):=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20import=EB=AC=B8=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/entity/DeletedDocument.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java index ff6bc1b8..5f1b352f 100644 --- a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java +++ b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java @@ -4,8 +4,6 @@ import static lombok.AccessLevel.PRIVATE; import static lombok.AccessLevel.PROTECTED; -import java.time.LocalDate; - import com.tiki.server.common.entity.BaseTime; import jakarta.persistence.Column; From d564abeb09f1f7547819494b36504e434c6ac7cd Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:30:51 +0900 Subject: [PATCH 057/101] =?UTF-8?q?feat(DocumentRepository):=20id=EC=99=80?= =?UTF-8?q?=20=ED=8C=80=20id=EB=A1=9C=20=ED=8C=8C=EC=9D=BC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/repository/DocumentRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java index 9704be04..8c34675c 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -1,6 +1,7 @@ package com.tiki.server.document.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -24,4 +25,6 @@ public interface DocumentRepository extends JpaRepository { void deleteAllByTimeBlockId(long timeBlockId); List findAllByTeamIdAndFolderIdOrderByCreatedAtDesc(long teamId, Long folderId); + + Optional findByIdAndTeamId(long id, long teamId); } From 3b8f971e6be92f4310c4fa81a038672143700852 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:31:27 +0900 Subject: [PATCH 058/101] =?UTF-8?q?fix(DocumentFinder):=20=EB=8B=A4?= =?UTF-8?q?=EB=A5=B8=20=ED=8C=80=20=ED=8C=8C=EC=9D=BC=20=EC=A0=91=EA=B7=BC?= =?UTF-8?q?=20=EA=B0=80=EB=8A=A5=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/adapter/DocumentFinder.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java index 4a24e1c9..c494a153 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -20,9 +20,9 @@ public class DocumentFinder { private final DocumentRepository documentRepository; - public List findAllById(final List documentIds) { + public List findAllById(final List documentIds, final long teamId) { return documentIds.stream() - .map(this::findByIdOrElseThrow) + .map(id -> findByIdAndTeamId(id, teamId)) .toList(); } @@ -57,4 +57,9 @@ public boolean existsById(Long timeBlockId) { public List findByTeamIdAndFolderId(final long teamId, final Long folderId) { return documentRepository.findAllByTeamIdAndFolderIdOrderByCreatedAtDesc(teamId, folderId); } + + private Document findByIdAndTeamId(long documentId, long teamId) { + return documentRepository.findByIdAndTeamId(documentId, teamId) + .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); + } } From d565d98d79c8b9fa88a48d730e84e8dc91a7b708 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:32:10 +0900 Subject: [PATCH 059/101] =?UTF-8?q?fix(DocumentService):=20=EB=8B=A4?= =?UTF-8?q?=EB=A5=B8=20=ED=8C=80=20=ED=8C=8C=EC=9D=BC=20=EC=A0=91=EA=B7=BC?= =?UTF-8?q?=20=EA=B0=80=EB=8A=A5=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/service/DocumentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 767da79e..70cbe3ec 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -69,7 +69,7 @@ public DocumentsGetResponse get(final long memberId, final long teamId, final Lo @Transactional public void delete(final long memberId, final long teamId, final List documentIds) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); - List documents = documentFinder.findAllById(documentIds); + List documents = documentFinder.findAllById(documentIds, teamId); deletedDocumentAdapter.save(documents, teamId); documentDeleter.deleteAll(documents); } From c07f50244348318ff32df2f11b794afc7452ed82 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:44:20 +0900 Subject: [PATCH 060/101] =?UTF-8?q?feat(DeletedDocumentRepository):=20id?= =?UTF-8?q?=EC=99=80=20=ED=8C=80=20id=EB=A1=9C=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/document/repository/DeletedDocumentRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java b/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java index f4595a5a..245b5db3 100644 --- a/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java @@ -1,8 +1,12 @@ package com.tiki.server.document.repository; +import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; import com.tiki.server.document.entity.DeletedDocument; public interface DeletedDocumentRepository extends JpaRepository { + + Optional findByIdAndTeamId(long id, long teamId); } From 21bbc7e2ef1a07dd1629c0b361e0d2545269dde8 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:44:58 +0900 Subject: [PATCH 061/101] =?UTF-8?q?feat(DeletedDocumentAdapter):=20id?= =?UTF-8?q?=EC=99=80=20=ED=8C=80=20id=EB=A1=9C=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/adapter/DeletedDocumentAdapter.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java index 39c685c7..8a9b101c 100644 --- a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java +++ b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java @@ -1,10 +1,13 @@ package com.tiki.server.document.adapter; +import static com.tiki.server.document.message.ErrorCode.INVALID_DOCUMENT; + import java.util.List; import com.tiki.server.common.support.RepositoryAdapter; import com.tiki.server.document.entity.DeletedDocument; import com.tiki.server.document.entity.Document; +import com.tiki.server.document.exception.DocumentException; import com.tiki.server.document.repository.DeletedDocumentRepository; import lombok.RequiredArgsConstructor; @@ -19,7 +22,18 @@ public void save(final List documents, final long teamId) { documents.forEach(document -> deletedDocumentRepository.save(create(document, teamId))); } + public List get(final List deletedDocumentIds, final long teamId) { + return deletedDocumentIds.stream() + .map(id -> find(id, teamId)) + .toList(); + } + private DeletedDocument create(final Document document, final long teamId) { return DeletedDocument.of(document.getFileName(), document.getFileUrl(), teamId, document.getCapacity()); } + + private DeletedDocument find(final long id, final long teamId) { + return deletedDocumentRepository.findByIdAndTeamId(id, teamId) + .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); + } } From dc7d17144ad6cbd9a0f64d6e251373090f9d3a58 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:45:18 +0900 Subject: [PATCH 062/101] =?UTF-8?q?feat(DeletedDocumentAdapter):=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=98=81=EA=B5=AC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/adapter/DeletedDocumentAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java index 8a9b101c..4dedd27a 100644 --- a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java +++ b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java @@ -28,6 +28,10 @@ public List get(final List deletedDocumentIds, final long .toList(); } + public void deleteAll(final List deletedDocuments) { + deletedDocumentRepository.deleteAll(deletedDocuments); + } + private DeletedDocument create(final Document document, final long teamId) { return DeletedDocument.of(document.getFileName(), document.getFileUrl(), teamId, document.getCapacity()); } From e59c381fe8e538bd153af107a84c559ffc3ab8ae Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:45:37 +0900 Subject: [PATCH 063/101] =?UTF-8?q?feat(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=98=81=EA=B5=AC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/service/DocumentService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 70cbe3ec..4a5b42b7 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -15,6 +15,7 @@ import com.tiki.server.document.dto.request.DocumentCreateRequest; import com.tiki.server.document.dto.request.DocumentsCreateRequest; import com.tiki.server.document.dto.response.DocumentsGetResponse; +import com.tiki.server.document.entity.DeletedDocument; import com.tiki.server.document.entity.Document; import com.tiki.server.document.exception.DocumentException; import com.tiki.server.folder.adapter.FolderFinder; @@ -74,6 +75,13 @@ public void delete(final long memberId, final long teamId, final List docu documentDeleter.deleteAll(documents); } + @Transactional + public void deleteTrash(final long memberId, final long teamId, final List documentIds) { + memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); + List deletedDocuments = deletedDocumentAdapter.get(documentIds, teamId); + deletedDocumentAdapter.deleteAll(deletedDocuments); + } + private DocumentsGetResponse getAllDocumentsByType(final long teamId, final Position accessiblePosition) { List documents = documentFinder.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); return DocumentsGetResponse.from(documents); From 45bc8e209e7e42c677c20ddba374e844a1504240 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:45:57 +0900 Subject: [PATCH 064/101] =?UTF-8?q?feat(DocumentController):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=98=81=EA=B5=AC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/controller/DocumentController.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index 28aecb58..33d082c1 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -91,4 +91,15 @@ public ResponseEntity delete( documentService.delete(memberId, teamId, documentIds); return ResponseEntity.noContent().build(); } + + @DeleteMapping("/teams/{teamId}/trash") + public ResponseEntity deleteTrash( + final Principal principal, + @PathVariable final long teamId, + @RequestParam final List deletedDocumentIds + ) { + long memberId = Long.parseLong(principal.getName()); + documentService.deleteTrash(memberId, teamId, deletedDocumentIds); + return ResponseEntity.noContent().build(); + } } From 68a9c00b4948e3cdaf6bcb80cf9627f6fc183ba6 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:54:46 +0900 Subject: [PATCH 065/101] =?UTF-8?q?feat(Document):=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=B3=B5=EA=B5=AC=20=EC=83=9D=EC=84=B1=EC=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/entity/Document.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/tiki/server/document/entity/Document.java b/src/main/java/com/tiki/server/document/entity/Document.java index 6af381b5..b734b362 100644 --- a/src/main/java/com/tiki/server/document/entity/Document.java +++ b/src/main/java/com/tiki/server/document/entity/Document.java @@ -66,4 +66,15 @@ public static Document of(String fileName, String fileUrl, double capacity, long .timeBlock(null) // TODO : 타임 블록 생성 api 수정 후 제거 예정 .build(); } + + public static Document restore(String fileName, String fileUrl, double capacity, long teamId) { + return Document.builder() + .fileName(fileName) + .fileUrl(fileUrl) + .capacity(capacity) + .teamId(teamId) + .folderId(null) + .timeBlock(null) + .build(); + } } From ebb2a96184a6e6b853c764523dd8b98e342fbfb3 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:55:36 +0900 Subject: [PATCH 066/101] =?UTF-8?q?feat(DocumentSaver):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=B3=B5=EA=B5=AC=20=EB=B0=8F=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/document/adapter/DocumentSaver.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java b/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java index 34872245..3447e488 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java @@ -1,6 +1,9 @@ package com.tiki.server.document.adapter; +import java.util.List; + import com.tiki.server.common.support.RepositoryAdapter; +import com.tiki.server.document.entity.DeletedDocument; import com.tiki.server.document.entity.Document; import com.tiki.server.document.repository.DocumentRepository; @@ -15,4 +18,17 @@ public class DocumentSaver { public Document save(Document document) { return documentRepository.save(document); } + + public void restore(List deletedDocuments) { + deletedDocuments.forEach(document -> documentRepository.save(create(document))); + } + + private Document create(DeletedDocument deletedDocument) { + return Document.restore( + deletedDocument.getFileName(), + deletedDocument.getFileUrl(), + deletedDocument.getCapacity(), + deletedDocument.getTeamId() + ); + } } From 89deecc8e5cdbfb49a3b831cc8c84c1255bb871c Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:56:00 +0900 Subject: [PATCH 067/101] =?UTF-8?q?feat(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/service/DocumentService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 4a5b42b7..85fecb18 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -82,6 +82,14 @@ public void deleteTrash(final long memberId, final long teamId, final List deletedDocumentAdapter.deleteAll(deletedDocuments); } + @Transactional + public void restore(final long memberId, final long teamId, final List documentIds) { + memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); + List deletedDocuments = deletedDocumentAdapter.get(documentIds, teamId); + documentSaver.restore(deletedDocuments); + deletedDocumentAdapter.deleteAll(deletedDocuments); + } + private DocumentsGetResponse getAllDocumentsByType(final long teamId, final Position accessiblePosition) { List documents = documentFinder.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); return DocumentsGetResponse.from(documents); From 1ea603298c5c5fddb5b33983c223785a65812402 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 19:56:18 +0900 Subject: [PATCH 068/101] =?UTF-8?q?feat(DocumentController):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/controller/DocumentController.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index 33d082c1..8f58287e 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -102,4 +102,15 @@ public ResponseEntity deleteTrash( documentService.deleteTrash(memberId, teamId, deletedDocumentIds); return ResponseEntity.noContent().build(); } + + @PostMapping("/teams/{teamId}/trash") + public ResponseEntity restore( + final Principal principal, + @PathVariable final long teamId, + @RequestParam final List deletedDocumentIds + ) { + long memberId = Long.parseLong(principal.getName()); + documentService.restore(memberId, teamId, deletedDocumentIds); + return ResponseEntity.noContent().build(); + } } From 0c8ba6f13c1049d60862dc3243e4e427fa44aec4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 20:01:03 +0900 Subject: [PATCH 069/101] =?UTF-8?q?chore(DocumentSaver):=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/adapter/DocumentSaver.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java b/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java index 3447e488..8648cb85 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java @@ -15,15 +15,15 @@ public class DocumentSaver { private final DocumentRepository documentRepository; - public Document save(Document document) { + public Document save(final Document document) { return documentRepository.save(document); } - public void restore(List deletedDocuments) { + public void restore(final List deletedDocuments) { deletedDocuments.forEach(document -> documentRepository.save(create(document))); } - private Document create(DeletedDocument deletedDocument) { + private Document create(final DeletedDocument deletedDocument) { return Document.restore( deletedDocument.getFileName(), deletedDocument.getFileUrl(), From 4e83a8d570d0a96227eec6b7f7010385bca20aae Mon Sep 17 00:00:00 2001 From: Chan531 Date: Mon, 25 Nov 2024 20:01:48 +0900 Subject: [PATCH 070/101] =?UTF-8?q?chore(Document):=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=20final=20=ED=82=A4=EC=9B=8C=EB=93=9C=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/entity/Document.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/document/entity/Document.java b/src/main/java/com/tiki/server/document/entity/Document.java index b734b362..814e8326 100644 --- a/src/main/java/com/tiki/server/document/entity/Document.java +++ b/src/main/java/com/tiki/server/document/entity/Document.java @@ -45,7 +45,7 @@ public class Document extends BaseTime { @JoinColumn(name = "block_id") private TimeBlock timeBlock; - public static Document of(String fileName, String fileUrl, TimeBlock timeBlock) { + public static Document of(final String fileName, final String fileUrl, final TimeBlock timeBlock) { return Document.builder() .fileName(fileName) .fileUrl(fileUrl) @@ -56,7 +56,8 @@ public static Document of(String fileName, String fileUrl, TimeBlock timeBlock) .build(); } - public static Document of(String fileName, String fileUrl, double capacity, long teamId, Long folderId) { + public static Document of(final String fileName, final String fileUrl, + final double capacity, final long teamId, final Long folderId) { return Document.builder() .fileName(fileName) .fileUrl(fileUrl) @@ -67,7 +68,8 @@ public static Document of(String fileName, String fileUrl, double capacity, long .build(); } - public static Document restore(String fileName, String fileUrl, double capacity, long teamId) { + public static Document restore(final String fileName, final String fileUrl, + final double capacity, final long teamId) { return Document.builder() .fileName(fileName) .fileUrl(fileUrl) From ef68c792ce5b907b5ef84788eb5365865418a717 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:32:34 +0900 Subject: [PATCH 071/101] =?UTF-8?q?feat(FolderDeleter):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/folder/adapter/FolderDeleter.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/adapter/FolderDeleter.java diff --git a/src/main/java/com/tiki/server/folder/adapter/FolderDeleter.java b/src/main/java/com/tiki/server/folder/adapter/FolderDeleter.java new file mode 100644 index 00000000..aecb7c68 --- /dev/null +++ b/src/main/java/com/tiki/server/folder/adapter/FolderDeleter.java @@ -0,0 +1,20 @@ +package com.tiki.server.folder.adapter; + +import java.util.List; + +import com.tiki.server.common.support.RepositoryAdapter; +import com.tiki.server.folder.entity.Folder; +import com.tiki.server.folder.repository.FolderRepository; + +import lombok.RequiredArgsConstructor; + +@RepositoryAdapter +@RequiredArgsConstructor +public class FolderDeleter { + + private final FolderRepository folderRepository; + + public void deleteAll(final List folders) { + folderRepository.deleteAll(folders); + } +} From 361ba79abd3afc424f44f61f0c1d88c4968fec09 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:33:10 +0900 Subject: [PATCH 072/101] =?UTF-8?q?feat(FolderRepository):=20id=EC=99=80?= =?UTF-8?q?=20=ED=8C=80=20id=EB=A1=9C=20=ED=8F=B4=EB=8D=94=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/repository/FolderRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/repository/FolderRepository.java b/src/main/java/com/tiki/server/folder/repository/FolderRepository.java index 34a11781..e6e1dcf2 100644 --- a/src/main/java/com/tiki/server/folder/repository/FolderRepository.java +++ b/src/main/java/com/tiki/server/folder/repository/FolderRepository.java @@ -1,6 +1,7 @@ package com.tiki.server.folder.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; @@ -9,4 +10,5 @@ public interface FolderRepository extends JpaRepository { List findAllByTeamIdAndPathOrderByCreatedAtDesc(long teamId, String path); List findAllByPathOrderByCreatedAtDesc(String path); + Optional findByIdAndTeamId(long id, long teamId); } From 26e51f042e368ca5f0da10bef04c6f4700aa87a5 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:33:32 +0900 Subject: [PATCH 073/101] =?UTF-8?q?feat(FolderRepository):=20path=EB=A1=9C?= =?UTF-8?q?=20=EC=8B=9C=EC=9E=91=ED=95=98=EB=8A=94=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/repository/FolderRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/tiki/server/folder/repository/FolderRepository.java b/src/main/java/com/tiki/server/folder/repository/FolderRepository.java index e6e1dcf2..d32d516f 100644 --- a/src/main/java/com/tiki/server/folder/repository/FolderRepository.java +++ b/src/main/java/com/tiki/server/folder/repository/FolderRepository.java @@ -11,4 +11,5 @@ public interface FolderRepository extends JpaRepository { List findAllByTeamIdAndPathOrderByCreatedAtDesc(long teamId, String path); List findAllByPathOrderByCreatedAtDesc(String path); Optional findByIdAndTeamId(long id, long teamId); + List findAllByPathStartsWith(String path); } From dc065a45121bdf77e78af74cc19e63fb1778aee7 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:34:16 +0900 Subject: [PATCH 074/101] =?UTF-8?q?feat(FolderFinder):=20path=EB=A1=9C=20?= =?UTF-8?q?=EC=8B=9C=EC=9E=91=ED=95=98=EB=8A=94=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/adapter/FolderFinder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java index 698cd55b..3d04357d 100644 --- a/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java +++ b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java @@ -29,4 +29,8 @@ public List findByTeamIdAndPath(final long teamId, final String path) { } return folderRepository.findAllByPathOrderByCreatedAtDesc(path); } + + public List findAllStartWithPath(final String path) { + return folderRepository.findAllByPathStartsWith(path); + } } From 2dfcf92aa2aadbb783bce95665ab2be378e1b7e2 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:35:01 +0900 Subject: [PATCH 075/101] =?UTF-8?q?feat(FolderFinder):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20id=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=EC=99=80=20?= =?UTF-8?q?=ED=8C=80=20id=EB=A1=9C=20=ED=8F=B4=EB=8D=94=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 폴더와 팀 id가 매칭되지 않는다면 예외 발생 --- .../com/tiki/server/folder/adapter/FolderFinder.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java index 3d04357d..5322af1c 100644 --- a/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java +++ b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java @@ -30,7 +30,18 @@ public List findByTeamIdAndPath(final long teamId, final String path) { return folderRepository.findAllByPathOrderByCreatedAtDesc(path); } + public List findAllById(final List folderIds, final long teamId) { + return folderIds.stream() + .map(id -> findByIdAndTeamId(id, teamId)) + .toList(); + } + public List findAllStartWithPath(final String path) { return folderRepository.findAllByPathStartsWith(path); } + + private Folder findByIdAndTeamId(final long id, final long teamId) { + return folderRepository.findByIdAndTeamId(id, teamId) + .orElseThrow(() -> new FolderException(INVALID_FOLDER)); + } } From d190ce11bab1950cd634ac591349fe05ee018075 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:36:55 +0900 Subject: [PATCH 076/101] =?UTF-8?q?feat(DocumentRepository):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20id=EB=A1=9C=20=ED=8C=8C=EC=9D=BC=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/repository/DocumentRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java index 8c34675c..879c6600 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -12,6 +12,8 @@ public interface DocumentRepository extends JpaRepository { List findAllByTimeBlockId(long timeBlockId); + List findAllByFolderId(long folderId); + @Query("select d from Document d join fetch d.timeBlock t " + "where t.team.id = :teamId and t.accessiblePosition = :position order by d.createdAt asc") List findAllByTeamIdAndAccessiblePosition(long teamId, Position position); From 8ee4414a5ff43a103fe8f6c159b0c7602d4d7e84 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:37:13 +0900 Subject: [PATCH 077/101] =?UTF-8?q?feat(DocumentFinder):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20id=EB=A1=9C=20=ED=8C=8C=EC=9D=BC=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/adapter/DocumentFinder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java index c494a153..4e76de91 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -58,6 +58,10 @@ public List findByTeamIdAndFolderId(final long teamId, final Long fold return documentRepository.findAllByTeamIdAndFolderIdOrderByCreatedAtDesc(teamId, folderId); } + public List findAllByFolderId(final long folderId) { + return documentRepository.findAllByFolderId(folderId); + } + private Document findByIdAndTeamId(long documentId, long teamId) { return documentRepository.findByIdAndTeamId(documentId, teamId) .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); From 4be74448983d7f31aa238e5fb85b1caaa90ef5ba Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:43:46 +0900 Subject: [PATCH 078/101] =?UTF-8?q?feat(FolderService):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EC=86=8D=20=ED=8C=8C=EC=9D=BC=20=ED=9C=B4=EC=A7=80?= =?UTF-8?q?=ED=86=B5=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/folder/service/FolderService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 21f27a77..06ac7888 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -8,6 +8,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.tiki.server.document.adapter.DeletedDocumentAdapter; +import com.tiki.server.document.adapter.DocumentDeleter; +import com.tiki.server.document.adapter.DocumentFinder; +import com.tiki.server.document.entity.Document; import com.tiki.server.folder.adapter.FolderFinder; import com.tiki.server.folder.adapter.FolderSaver; import com.tiki.server.folder.dto.request.FolderCreateRequest; @@ -27,6 +31,9 @@ public class FolderService { private final FolderFinder folderFinder; private final FolderSaver folderSaver; private final MemberTeamManagerFinder memberTeamManagerFinder; + private final DocumentFinder documentFinder; + private final DocumentDeleter documentDeleter; + private final DeletedDocumentAdapter deletedDocumentAdapter; public FoldersGetResponse get(final long memberId, final long teamId, final Long folderId) { @@ -70,4 +77,10 @@ private void validateFolderName(final long teamId, final String path, final Fold throw new FolderException(FOLDER_NAME_DUPLICATE); } } + + private void deleteDocuments(final Folder folder, final long teamId) { + List documents = documentFinder.findAllByFolderId(folder.getId()); + deletedDocumentAdapter.save(documents, teamId); + documentDeleter.deleteAll(documents); + } } From b329d6bc9553000aacef6b71e212394c58f92eed Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:44:26 +0900 Subject: [PATCH 079/101] =?UTF-8?q?feat(FolderService):=20=EC=9E=90?= =?UTF-8?q?=EC=8B=9D=20=ED=8F=B4=EB=8D=94=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/service/FolderService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 06ac7888..a9b189df 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -12,6 +12,7 @@ import com.tiki.server.document.adapter.DocumentDeleter; import com.tiki.server.document.adapter.DocumentFinder; import com.tiki.server.document.entity.Document; +import com.tiki.server.folder.adapter.FolderDeleter; import com.tiki.server.folder.adapter.FolderFinder; import com.tiki.server.folder.adapter.FolderSaver; import com.tiki.server.folder.dto.request.FolderCreateRequest; @@ -19,6 +20,7 @@ import com.tiki.server.folder.dto.response.FoldersGetResponse; import com.tiki.server.folder.entity.Folder; import com.tiki.server.folder.exception.FolderException; +import com.tiki.server.folder.repository.FolderRepository; import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; import lombok.RequiredArgsConstructor; @@ -34,6 +36,7 @@ public class FolderService { private final DocumentFinder documentFinder; private final DocumentDeleter documentDeleter; private final DeletedDocumentAdapter deletedDocumentAdapter; + private final FolderDeleter folderDeleter; public FoldersGetResponse get(final long memberId, final long teamId, final Long folderId) { @@ -78,6 +81,12 @@ private void validateFolderName(final long teamId, final String path, final Fold } } + private void deleteChildFolders(final Folder folder, final long teamId) { + List childFolders = folderFinder.findAllStartWithPath(folder.getChildPath()); + childFolders.forEach(childFolder -> deleteDocuments(childFolder, teamId)); + folderDeleter.deleteAll(childFolders); + } + private void deleteDocuments(final Folder folder, final long teamId) { List documents = documentFinder.findAllByFolderId(folder.getId()); deletedDocumentAdapter.save(documents, teamId); From 3040847ec404d34af6469e08e7d2ab8769ab9987 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:45:18 +0900 Subject: [PATCH 080/101] =?UTF-8?q?feat(FolderService):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/service/FolderService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index a9b189df..e923df5e 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -20,7 +20,6 @@ import com.tiki.server.folder.dto.response.FoldersGetResponse; import com.tiki.server.folder.entity.Folder; import com.tiki.server.folder.exception.FolderException; -import com.tiki.server.folder.repository.FolderRepository; import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; import lombok.RequiredArgsConstructor; @@ -81,6 +80,11 @@ private void validateFolderName(final long teamId, final String path, final Fold } } + private void deleteFolders(final List folders, final long teamId) { + folders.forEach(folder -> deleteChildFolders(folder, teamId)); + folderDeleter.deleteAll(folders); + } + private void deleteChildFolders(final Folder folder, final long teamId) { List childFolders = folderFinder.findAllStartWithPath(folder.getChildPath()); childFolders.forEach(childFolder -> deleteDocuments(childFolder, teamId)); From fb4a27c248c33dbd8e0e9c8ab9b3758721f9deb8 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:45:42 +0900 Subject: [PATCH 081/101] =?UTF-8?q?feat(FolderService):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/service/FolderService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index e923df5e..fd9e33a1 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -57,6 +57,13 @@ public FolderCreateResponse create(final long memberId, final long teamId, return FolderCreateResponse.from(folder.getId()); } + @Transactional + public void delete(final long memberId, final long teamId, final List folderIds) { + memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); + List folders = folderFinder.findAllById(folderIds, teamId); + deleteFolders(folders, teamId); + } + private Folder getFolder(final long teamId, final Long folderId) { if (folderId == null) { return null; From 2223bae2f0a9b60080ad591ce3703bddc427c19f Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:46:40 +0900 Subject: [PATCH 082/101] =?UTF-8?q?feat(FolderController):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/folder/controller/FolderController.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index 9c8602ff..ea36a843 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -6,8 +6,10 @@ import static com.tiki.server.folder.message.SuccessMessage.SUCCESS_GET_FOLDERS; import java.security.Principal; +import java.util.List; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -55,4 +57,15 @@ public ResponseEntity> createFolder( return ResponseEntity.created(UriGenerator.getUri("api/v1/folders/" + response.folderId())) .body(success(SUCCESS_CREATE_FOLDER.getMessage(), response)); } + + @DeleteMapping("/teams/{teamId}/folders") + public ResponseEntity delete( + final Principal principal, + @PathVariable final long teamId, + @RequestParam final List folderIds + ) { + long memberId = Long.parseLong(principal.getName()); + folderService.delete(memberId, teamId, folderIds); + return ResponseEntity.noContent().build(); + } } From d7489781b63ba1ddbcfb81c6618d40d3c029b56e Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:46:55 +0900 Subject: [PATCH 083/101] =?UTF-8?q?chore(FolderController):=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20import=EB=AC=B8=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/controller/FolderController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index ea36a843..79931dd8 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -1,7 +1,6 @@ package com.tiki.server.folder.controller; import static com.tiki.server.common.dto.SuccessResponse.*; -import static com.tiki.server.folder.constant.Constant.ROOT_PATH; import static com.tiki.server.folder.message.SuccessMessage.SUCCESS_CREATE_FOLDER; import static com.tiki.server.folder.message.SuccessMessage.SUCCESS_GET_FOLDERS; From 68256d7eb1e0b31347aeef46ee874aac258cafc4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:48:30 +0900 Subject: [PATCH 084/101] =?UTF-8?q?refactor(FolderController):=20Uri=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/controller/FolderController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index 79931dd8..1b2d842e 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -53,8 +53,9 @@ public ResponseEntity> createFolder( ) { long memberId = Long.parseLong(principal.getName()); FolderCreateResponse response = folderService.create(memberId, teamId, folderId, request); - return ResponseEntity.created(UriGenerator.getUri("api/v1/folders/" + response.folderId())) - .body(success(SUCCESS_CREATE_FOLDER.getMessage(), response)); + return ResponseEntity.created( + UriGenerator.getUri("api/v1/teams/" + teamId + "/folders/" + response.folderId())) + .body(success(SUCCESS_CREATE_FOLDER.getMessage(), response)); } @DeleteMapping("/teams/{teamId}/folders") From cf03aa11cedf725061334da3c4f487c7cb5df2b1 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 15:58:28 +0900 Subject: [PATCH 085/101] =?UTF-8?q?fix(FolderService):=20=EB=B6=80?= =?UTF-8?q?=EB=AA=A8=20=ED=8F=B4=EB=8D=94=20=EC=86=8D=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20=EB=88=84=EB=9D=BD=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/service/FolderService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index fd9e33a1..945f75df 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -62,6 +62,7 @@ public void delete(final long memberId, final long teamId, final List fold memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); List folders = folderFinder.findAllById(folderIds, teamId); deleteFolders(folders, teamId); + folders.forEach(folder -> deleteDocuments(folder, teamId)); } private Folder getFolder(final long teamId, final Long folderId) { From 207545f20bc8ea9f24b04b27d1ddc53171991db0 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 16:00:45 +0900 Subject: [PATCH 086/101] =?UTF-8?q?refactor(DeletedDocumentAdapter):=20?= =?UTF-8?q?=ED=8C=80=20id=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit document.getTeamId()로 대체 --- .../tiki/server/document/adapter/DeletedDocumentAdapter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java index 4dedd27a..15d51d7e 100644 --- a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java +++ b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java @@ -18,8 +18,8 @@ public class DeletedDocumentAdapter { private final DeletedDocumentRepository deletedDocumentRepository; - public void save(final List documents, final long teamId) { - documents.forEach(document -> deletedDocumentRepository.save(create(document, teamId))); + public void save(final List documents) { + documents.forEach(document -> deletedDocumentRepository.save(create(document, document.getTeamId()))); } public List get(final List deletedDocumentIds, final long teamId) { From 597d74d14493ec476b81e8243f381fe298270f30 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 16:01:00 +0900 Subject: [PATCH 087/101] =?UTF-8?q?refactor(DocumentService):=20=ED=8C=80?= =?UTF-8?q?=20id=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/service/DocumentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 85fecb18..97956c02 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -71,7 +71,7 @@ public DocumentsGetResponse get(final long memberId, final long teamId, final Lo public void delete(final long memberId, final long teamId, final List documentIds) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); List documents = documentFinder.findAllById(documentIds, teamId); - deletedDocumentAdapter.save(documents, teamId); + deletedDocumentAdapter.save(documents); documentDeleter.deleteAll(documents); } From ae3cf77b01064a83f14b6268448ed02fd1cd2b36 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 16:01:26 +0900 Subject: [PATCH 088/101] =?UTF-8?q?refactor(FolderService):=20=ED=8C=80=20?= =?UTF-8?q?id=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=A0=9C=EA=B1=B0?= =?UTF-8?q?=20=EB=B0=8F=20=EB=9E=8C=EB=8B=A4=EC=8B=9D=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/folder/service/FolderService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 945f75df..7ae19d31 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -61,8 +61,8 @@ public FolderCreateResponse create(final long memberId, final long teamId, public void delete(final long memberId, final long teamId, final List folderIds) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); List folders = folderFinder.findAllById(folderIds, teamId); - deleteFolders(folders, teamId); - folders.forEach(folder -> deleteDocuments(folder, teamId)); + deleteFolders(folders); + folders.forEach(this::deleteDocuments); } private Folder getFolder(final long teamId, final Long folderId) { @@ -88,20 +88,20 @@ private void validateFolderName(final long teamId, final String path, final Fold } } - private void deleteFolders(final List folders, final long teamId) { - folders.forEach(folder -> deleteChildFolders(folder, teamId)); + private void deleteFolders(final List folders) { + folders.forEach(this::deleteChildFolders); folderDeleter.deleteAll(folders); } - private void deleteChildFolders(final Folder folder, final long teamId) { + private void deleteChildFolders(final Folder folder) { List childFolders = folderFinder.findAllStartWithPath(folder.getChildPath()); - childFolders.forEach(childFolder -> deleteDocuments(childFolder, teamId)); + childFolders.forEach(this::deleteDocuments); folderDeleter.deleteAll(childFolders); } - private void deleteDocuments(final Folder folder, final long teamId) { + private void deleteDocuments(final Folder folder) { List documents = documentFinder.findAllByFolderId(folder.getId()); - deletedDocumentAdapter.save(documents, teamId); + deletedDocumentAdapter.save(documents); documentDeleter.deleteAll(documents); } } From e2bf6b78121094eeaafa3cca6e0a3fbf3e13ba54 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 16:02:46 +0900 Subject: [PATCH 089/101] =?UTF-8?q?refactor(DocumentFinder):=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 메소드 명에 teamId 추가 --- .../java/com/tiki/server/document/adapter/DocumentFinder.java | 2 +- .../java/com/tiki/server/document/service/DocumentService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java index 4e76de91..fdcc7546 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -20,7 +20,7 @@ public class DocumentFinder { private final DocumentRepository documentRepository; - public List findAllById(final List documentIds, final long teamId) { + public List findAllByIdAndTeamId(final List documentIds, final long teamId) { return documentIds.stream() .map(id -> findByIdAndTeamId(id, teamId)) .toList(); diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 97956c02..1ae3c7f7 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -70,7 +70,7 @@ public DocumentsGetResponse get(final long memberId, final long teamId, final Lo @Transactional public void delete(final long memberId, final long teamId, final List documentIds) { memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); - List documents = documentFinder.findAllById(documentIds, teamId); + List documents = documentFinder.findAllByIdAndTeamId(documentIds, teamId); deletedDocumentAdapter.save(documents); documentDeleter.deleteAll(documents); } From 4d41d7b1904cc461f2951a4cf8e733d7672bfc27 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 16:03:33 +0900 Subject: [PATCH 090/101] =?UTF-8?q?refactor(DocumentService):=20forEach=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/service/DocumentService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 1ae3c7f7..9ac9196e 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -105,9 +105,7 @@ private void validateFolder(final Long folderId, final long teamId) { private void validateFileName(final Long folderId, final long teamId, final DocumentsCreateRequest request) { List documents = documentFinder.findByTeamIdAndFolderId(teamId, folderId); - for (Document document : documents) { - checkFileNameIsDuplicated(document.getFileName(), request); - } + documents.forEach(document -> checkFileNameIsDuplicated(document.getFileName(), request)); } private void checkFileNameIsDuplicated(final String fileName, final DocumentsCreateRequest request) { From 10a048968cf92179acc7be7d76c7aa4fcbaa1c2e Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 16:17:19 +0900 Subject: [PATCH 091/101] =?UTF-8?q?refactor(DocumentController):=20Request?= =?UTF-8?q?Param=20url=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/controller/DocumentController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index 8f58287e..c668de81 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -85,7 +85,7 @@ public ResponseEntity> getDocuments( public ResponseEntity delete( final Principal principal, @PathVariable final long teamId, - @RequestParam final List documentIds + @RequestParam("documentId") final List documentIds ) { long memberId = Long.parseLong(principal.getName()); documentService.delete(memberId, teamId, documentIds); @@ -96,7 +96,7 @@ public ResponseEntity delete( public ResponseEntity deleteTrash( final Principal principal, @PathVariable final long teamId, - @RequestParam final List deletedDocumentIds + @RequestParam("documentId") final List deletedDocumentIds ) { long memberId = Long.parseLong(principal.getName()); documentService.deleteTrash(memberId, teamId, deletedDocumentIds); @@ -107,7 +107,7 @@ public ResponseEntity deleteTrash( public ResponseEntity restore( final Principal principal, @PathVariable final long teamId, - @RequestParam final List deletedDocumentIds + @RequestParam("documentId") final List deletedDocumentIds ) { long memberId = Long.parseLong(principal.getName()); documentService.restore(memberId, teamId, deletedDocumentIds); From b4f4367f36394cac26108ae856d07df69659b92b Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 26 Nov 2024 16:17:25 +0900 Subject: [PATCH 092/101] =?UTF-8?q?refactor(FolderController):=20RequestPa?= =?UTF-8?q?ram=20url=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/controller/FolderController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java index 1b2d842e..5d5c4c0e 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -62,7 +62,7 @@ public ResponseEntity> createFolder( public ResponseEntity delete( final Principal principal, @PathVariable final long teamId, - @RequestParam final List folderIds + @RequestParam("folderId") final List folderIds ) { long memberId = Long.parseLong(principal.getName()); folderService.delete(memberId, teamId, folderIds); From 1bebeb8e3a5227945ab02ee670ecea35b2ffa795 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 16:25:21 +0900 Subject: [PATCH 093/101] =?UTF-8?q?style(DocumentRepository):=20=ED=95=9C?= =?UTF-8?q?=20=EC=A4=84=20=EB=9D=84=EC=96=B4=EC=93=B0=EA=B8=B0=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/repository/DocumentRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java index 879c6600..63c4dfc2 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -10,6 +10,7 @@ import com.tiki.server.document.entity.Document; public interface DocumentRepository extends JpaRepository { + List findAllByTimeBlockId(long timeBlockId); List findAllByFolderId(long folderId); From 03a4d2086758fc7b869a46445729148dae7865c4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 16:25:31 +0900 Subject: [PATCH 094/101] =?UTF-8?q?style(FolderRepository):=20=ED=95=9C=20?= =?UTF-8?q?=EC=A4=84=20=EB=9D=84=EC=96=B4=EC=93=B0=EA=B8=B0=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/repository/FolderRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/repository/FolderRepository.java b/src/main/java/com/tiki/server/folder/repository/FolderRepository.java index d32d516f..beb0c697 100644 --- a/src/main/java/com/tiki/server/folder/repository/FolderRepository.java +++ b/src/main/java/com/tiki/server/folder/repository/FolderRepository.java @@ -8,8 +8,12 @@ import com.tiki.server.folder.entity.Folder; public interface FolderRepository extends JpaRepository { + List findAllByTeamIdAndPathOrderByCreatedAtDesc(long teamId, String path); + List findAllByPathOrderByCreatedAtDesc(String path); + Optional findByIdAndTeamId(long id, long teamId); + List findAllByPathStartsWith(String path); } From 5daa63a07bcb28f5113e69566f8ac435c63e218a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 16:42:29 +0900 Subject: [PATCH 095/101] =?UTF-8?q?feat(DeletedDocumentRepository):=20?= =?UTF-8?q?=ED=8C=80=20id=EB=A1=9C=20=EC=82=AD=EC=A0=9C=EB=90=9C=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/document/repository/DeletedDocumentRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java b/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java index 245b5db3..f978ba57 100644 --- a/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DeletedDocumentRepository.java @@ -1,5 +1,6 @@ package com.tiki.server.document.repository; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; @@ -9,4 +10,6 @@ public interface DeletedDocumentRepository extends JpaRepository { Optional findByIdAndTeamId(long id, long teamId); + + List findAllByTeamId(long teamId); } From 604b1fe6a998c0392ce3e29c8ad381a4b889e649 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 16:42:47 +0900 Subject: [PATCH 096/101] =?UTF-8?q?feat(SuccessMessage):=20=ED=9C=B4?= =?UTF-8?q?=EC=A7=80=ED=86=B5=20=EC=A1=B0=ED=9A=8C=20=EC=84=B1=EA=B3=B5=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/document/message/SuccessMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/document/message/SuccessMessage.java b/src/main/java/com/tiki/server/document/message/SuccessMessage.java index 78355728..315fceee 100644 --- a/src/main/java/com/tiki/server/document/message/SuccessMessage.java +++ b/src/main/java/com/tiki/server/document/message/SuccessMessage.java @@ -8,7 +8,8 @@ public enum SuccessMessage { SUCCESS_CREATE_DOCUMENTS("파일 생성 성공"), - SUCCESS_GET_DOCUMENTS("전체 문서 조회 성공"); + SUCCESS_GET_DOCUMENTS("전체 문서 조회 성공"), + SUCCESS_GET_TRASH("휴지통 조회 성공"); private final String message; } From ee3223680d326b0deaa3a352e72037f0cb9ffb85 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 16:43:00 +0900 Subject: [PATCH 097/101] =?UTF-8?q?feat(DeletedDocumentsGetResponse):=20?= =?UTF-8?q?=ED=9C=B4=EC=A7=80=ED=86=B5=20=EC=A1=B0=ED=9A=8C=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/DeletedDocumentsGetResponse.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/tiki/server/document/dto/response/DeletedDocumentsGetResponse.java diff --git a/src/main/java/com/tiki/server/document/dto/response/DeletedDocumentsGetResponse.java b/src/main/java/com/tiki/server/document/dto/response/DeletedDocumentsGetResponse.java new file mode 100644 index 00000000..cdae1fd8 --- /dev/null +++ b/src/main/java/com/tiki/server/document/dto/response/DeletedDocumentsGetResponse.java @@ -0,0 +1,40 @@ +package com.tiki.server.document.dto.response; + +import static lombok.AccessLevel.PRIVATE; + +import java.util.List; + +import com.tiki.server.document.entity.DeletedDocument; + +import lombok.Builder; +import lombok.NonNull; + +@Builder(access = PRIVATE) +public record DeletedDocumentsGetResponse( + List deletedDocuments +) { + + public static DeletedDocumentsGetResponse from(final List deletedDocuments) { + return DeletedDocumentsGetResponse.builder() + .deletedDocuments(deletedDocuments.stream().map(DeletedDocumentGetResponse::from).toList()) + .build(); + } + + @Builder(access = PRIVATE) + private record DeletedDocumentGetResponse( + long documentId, + @NonNull String name, + @NonNull String url, + double capacity + ) { + + private static DeletedDocumentGetResponse from(final DeletedDocument deletedDocument) { + return DeletedDocumentGetResponse.builder() + .documentId(deletedDocument.getId()) + .name(deletedDocument.getFileName()) + .url(deletedDocument.getFileUrl()) + .capacity(deletedDocument.getCapacity()) + .build(); + } + } +} From 7b92307c903f8bbcf42eb0e0b09d8826463affeb Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 16:43:17 +0900 Subject: [PATCH 098/101] =?UTF-8?q?feat(DeletedDocumentAdapter):=20?= =?UTF-8?q?=ED=8C=80=20id=EB=A1=9C=20=EC=82=AD=EC=A0=9C=EB=90=9C=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/document/adapter/DeletedDocumentAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java index 15d51d7e..2d46afe8 100644 --- a/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java +++ b/src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.java @@ -18,6 +18,10 @@ public class DeletedDocumentAdapter { private final DeletedDocumentRepository deletedDocumentRepository; + public List get(final long teamId) { + return deletedDocumentRepository.findAllByTeamId(teamId); + } + public void save(final List documents) { documents.forEach(document -> deletedDocumentRepository.save(create(document, document.getTeamId()))); } From d8d7ae06fea7ec0bac2ac845dc6e6474620f9c7e Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 16:43:31 +0900 Subject: [PATCH 099/101] =?UTF-8?q?feat(DocumentService):=20=ED=9C=B4?= =?UTF-8?q?=EC=A7=80=ED=86=B5=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/service/DocumentService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/tiki/server/document/service/DocumentService.java b/src/main/java/com/tiki/server/document/service/DocumentService.java index 9ac9196e..2acadc30 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -14,6 +14,7 @@ import com.tiki.server.document.adapter.DocumentSaver; import com.tiki.server.document.dto.request.DocumentCreateRequest; import com.tiki.server.document.dto.request.DocumentsCreateRequest; +import com.tiki.server.document.dto.response.DeletedDocumentsGetResponse; import com.tiki.server.document.dto.response.DocumentsGetResponse; import com.tiki.server.document.entity.DeletedDocument; import com.tiki.server.document.entity.Document; @@ -90,6 +91,12 @@ public void restore(final long memberId, final long teamId, final List doc deletedDocumentAdapter.deleteAll(deletedDocuments); } + public DeletedDocumentsGetResponse getTrash(final long memberId, final long teamId) { + memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); + List deletedDocuments = deletedDocumentAdapter.get(teamId); + return DeletedDocumentsGetResponse.from(deletedDocuments); + } + private DocumentsGetResponse getAllDocumentsByType(final long teamId, final Position accessiblePosition) { List documents = documentFinder.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); return DocumentsGetResponse.from(documents); From f145dc408810c7d2164b4a8094bef8294f92e51a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 16:43:49 +0900 Subject: [PATCH 100/101] =?UTF-8?q?feat(DocumentController):=20=ED=9C=B4?= =?UTF-8?q?=EC=A7=80=ED=86=B5=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/controller/DocumentController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/tiki/server/document/controller/DocumentController.java b/src/main/java/com/tiki/server/document/controller/DocumentController.java index c668de81..21960d56 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -2,6 +2,7 @@ import static com.tiki.server.document.message.SuccessMessage.SUCCESS_CREATE_DOCUMENTS; import static com.tiki.server.document.message.SuccessMessage.SUCCESS_GET_DOCUMENTS; +import static com.tiki.server.document.message.SuccessMessage.SUCCESS_GET_TRASH; import java.security.Principal; import java.util.List; @@ -20,6 +21,7 @@ import com.tiki.server.common.support.UriGenerator; import com.tiki.server.document.controller.docs.DocumentControllerDocs; import com.tiki.server.document.dto.request.DocumentsCreateRequest; +import com.tiki.server.document.dto.response.DeletedDocumentsGetResponse; import com.tiki.server.document.dto.response.DocumentsCreateResponse; import com.tiki.server.document.dto.response.DocumentsGetResponse; import com.tiki.server.document.service.DocumentService; @@ -113,4 +115,14 @@ public ResponseEntity restore( documentService.restore(memberId, teamId, deletedDocumentIds); return ResponseEntity.noContent().build(); } + + @GetMapping("/teams/{teamId}/trash") + public ResponseEntity> getTrash( + final Principal principal, + @PathVariable final long teamId + ) { + long memberId = Long.parseLong(principal.getName()); + DeletedDocumentsGetResponse response = documentService.getTrash(memberId, teamId); + return ResponseEntity.ok(SuccessResponse.success(SUCCESS_GET_TRASH.getMessage(), response)); + } } From 547f232592e640ceaea3957f770992c11ac44dbc Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 27 Nov 2024 17:11:52 +0900 Subject: [PATCH 101/101] =?UTF-8?q?refactor(FolderService):=20=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20=EC=86=8D=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/tiki/server/folder/service/FolderService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java index 7ae19d31..2be875a0 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -62,7 +62,6 @@ public void delete(final long memberId, final long teamId, final List fold memberTeamManagerFinder.findByMemberIdAndTeamIdOrElseThrow(memberId, teamId); List folders = folderFinder.findAllById(folderIds, teamId); deleteFolders(folders); - folders.forEach(this::deleteDocuments); } private Folder getFolder(final long teamId, final Long folderId) { @@ -90,6 +89,7 @@ private void validateFolderName(final long teamId, final String path, final Fold private void deleteFolders(final List folders) { folders.forEach(this::deleteChildFolders); + folders.forEach(this::deleteDocuments); folderDeleter.deleteAll(folders); }