From 2d76e90bb6ad247d6facc0f27341efeb44207f39 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 22 Oct 2024 20:42:40 +0900 Subject: [PATCH 01/20] =?UTF-8?q?[INIT]=20=ED=8C=8C=EC=9D=BC=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=EC=97=90=20=ED=8F=B4=EB=8D=94=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=EB=94=94=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/document/entity/Document.java | 2 ++ 1 file changed, 2 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 1c9de49b..a775bade 100644 --- a/src/main/java/com/tiki/server/document/entity/Document.java +++ b/src/main/java/com/tiki/server/document/entity/Document.java @@ -35,6 +35,8 @@ public class Document extends BaseTime { private String fileUrl; + private Long folderId; + @ManyToOne(fetch = LAZY) @JoinColumn(name = "block_id") private TimeBlock timeBlock; From 13e1ff919fd33b76ee314c7897910a386c9f3189 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 22 Oct 2024 20:42:54 +0900 Subject: [PATCH 02/20] =?UTF-8?q?[INIT]=20=ED=8C=8C=EC=9D=BC=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=EC=97=90=20=EC=9A=A9=EB=9F=89=20=EC=A0=95=EB=B3=B4=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/document/entity/Document.java | 2 ++ 1 file changed, 2 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 a775bade..e1ea3d1e 100644 --- a/src/main/java/com/tiki/server/document/entity/Document.java +++ b/src/main/java/com/tiki/server/document/entity/Document.java @@ -37,6 +37,8 @@ public class Document extends BaseTime { private Long folderId; + private double capacity; + @ManyToOne(fetch = LAZY) @JoinColumn(name = "block_id") private TimeBlock timeBlock; From 3cf4f221f80f4e03e32aac4a49ef9185624974d9 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Tue, 22 Oct 2024 21:03:02 +0900 Subject: [PATCH 03/20] =?UTF-8?q?[CHORE]=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=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/service/DocumentService.java | 4 ---- 1 file changed, 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 a6f8d00a..b9f1751c 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -1,9 +1,6 @@ package com.tiki.server.document.service; -import static com.tiki.server.document.message.ErrorCode.INVALID_DOCUMENT; - import java.util.List; -import java.util.Objects; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -13,7 +10,6 @@ import com.tiki.server.document.adapter.DocumentFinder; 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.memberteammanager.adapter.MemberTeamManagerFinder; import com.tiki.server.memberteammanager.entity.MemberTeamManager; From 7889360f542ed33894ca3812ab750f2e109b8eb1 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 23 Oct 2024 18:18:33 +0900 Subject: [PATCH 04/20] =?UTF-8?q?[INIT]=20=ED=8F=B4=EB=8D=94=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/entity/Folder.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/entity/Folder.java diff --git a/src/main/java/com/tiki/server/folder/entity/Folder.java b/src/main/java/com/tiki/server/folder/entity/Folder.java new file mode 100644 index 00000000..21145e84 --- /dev/null +++ b/src/main/java/com/tiki/server/folder/entity/Folder.java @@ -0,0 +1,40 @@ +package com.tiki.server.folder.entity; + +import static jakarta.persistence.GenerationType.IDENTITY; + +import com.tiki.server.common.entity.BaseTime; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +public class Folder extends BaseTime { + + @Id + @GeneratedValue(strategy = IDENTITY) + private Long id; + + private String name; + + private String path; + + private long teamId; + + public Folder(String name, Folder parentFolder, long teamId) { + this.name = name; + this.path = generatePath(parentFolder); + this.teamId = teamId; + } + + private String generatePath(Folder parentFolder) { + if (parentFolder == null) { + return ""; + } + return parentFolder.getPath() + "/" + parentFolder.getId(); + } +} From 4ad5f1d8d76b18130179ec0f39faf36ee99f0b07 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 23 Oct 2024 18:21:42 +0900 Subject: [PATCH 05/20] =?UTF-8?q?[INIT]=20Folder=20Repository=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/folder/repository/FolderRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/repository/FolderRepository.java diff --git a/src/main/java/com/tiki/server/folder/repository/FolderRepository.java b/src/main/java/com/tiki/server/folder/repository/FolderRepository.java new file mode 100644 index 00000000..8957660a --- /dev/null +++ b/src/main/java/com/tiki/server/folder/repository/FolderRepository.java @@ -0,0 +1,8 @@ +package com.tiki.server.folder.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.tiki.server.folder.entity.Folder; + +public interface FolderRepository extends JpaRepository { +} From eea41bee5cd01759017568b030ff8b78671f3409 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 23 Oct 2024 18:22:38 +0900 Subject: [PATCH 06/20] =?UTF-8?q?[INIT]=20Folder=20Service=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/folder/service/FolderService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/service/FolderService.java diff --git a/src/main/java/com/tiki/server/folder/service/FolderService.java b/src/main/java/com/tiki/server/folder/service/FolderService.java new file mode 100644 index 00000000..9a7e2cab --- /dev/null +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -0,0 +1,17 @@ +package com.tiki.server.folder.service; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.tiki.server.folder.repository.FolderRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class FolderService { + + private final FolderRepository folderRepository; + +} From ae3d1532284f14ef9d4be8d1a973c09e16bf67c2 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 23 Oct 2024 18:23:08 +0900 Subject: [PATCH 07/20] =?UTF-8?q?[INIT]=20Folder=20Controller=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../folder/controller/FolderController.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/controller/FolderController.java diff --git a/src/main/java/com/tiki/server/folder/controller/FolderController.java b/src/main/java/com/tiki/server/folder/controller/FolderController.java new file mode 100644 index 00000000..de4aacd1 --- /dev/null +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -0,0 +1,20 @@ +package com.tiki.server.folder.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.tiki.server.folder.service.FolderService; + +import lombok.RequiredArgsConstructor; + +@RestController +@RequiredArgsConstructor +@RequestMapping("api/v2/folders") +public class FolderController { + + private final FolderService folderService; + + /* + 폴더 생성하기 + */ +} From 4918dceaaab162b16f280a87571eb044455c7fa3 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 23 Oct 2024 18:24:02 +0900 Subject: [PATCH 08/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20Request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/folder/dto/request/FolderCreateRequest.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/dto/request/FolderCreateRequest.java 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 new file mode 100644 index 00000000..af4aa4f8 --- /dev/null +++ b/src/main/java/com/tiki/server/folder/dto/request/FolderCreateRequest.java @@ -0,0 +1,9 @@ +package com.tiki.server.folder.dto.request; + +import lombok.NonNull; + +public record FolderCreateRequest( + @NonNull String name, + Long parentId +) { +} From 7e30c472251cf1f5ae79623aef0acedd1f0aded2 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 23 Oct 2024 18:24:55 +0900 Subject: [PATCH 09/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20Response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/FolderCreateResponse.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/dto/response/FolderCreateResponse.java diff --git a/src/main/java/com/tiki/server/folder/dto/response/FolderCreateResponse.java b/src/main/java/com/tiki/server/folder/dto/response/FolderCreateResponse.java new file mode 100644 index 00000000..dcb75cfb --- /dev/null +++ b/src/main/java/com/tiki/server/folder/dto/response/FolderCreateResponse.java @@ -0,0 +1,17 @@ +package com.tiki.server.folder.dto.response; + +import static lombok.AccessLevel.PRIVATE; + +import lombok.Builder; + +@Builder(access = PRIVATE) +public record FolderCreateResponse( + long folderId +) { + + public static FolderCreateResponse from(long folderId) { + return FolderCreateResponse.builder() + .folderId(folderId) + .build(); + } +} From 2a73ccad9931d78f919a2e3a923aa53714ea16ce Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:56:41 +0900 Subject: [PATCH 10/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/message/ErrorCode.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/message/ErrorCode.java diff --git a/src/main/java/com/tiki/server/folder/message/ErrorCode.java b/src/main/java/com/tiki/server/folder/message/ErrorCode.java new file mode 100644 index 00000000..3a549a1c --- /dev/null +++ b/src/main/java/com/tiki/server/folder/message/ErrorCode.java @@ -0,0 +1,9 @@ +package com.tiki.server.folder.message; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ErrorCode { +} From 3c3f245c467eb1cfdb213a774b397a1d2971c889 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:57:15 +0900 Subject: [PATCH 11/20] =?UTF-8?q?[FEAT]=20=EC=9C=A0=ED=9A=A8=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=80=20=ED=8F=B4=EB=8D=94=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=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/folder/message/ErrorCode.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 3a549a1c..2ffa4988 100644 --- a/src/main/java/com/tiki/server/folder/message/ErrorCode.java +++ b/src/main/java/com/tiki/server/folder/message/ErrorCode.java @@ -1,9 +1,19 @@ package com.tiki.server.folder.message; +import static org.springframework.http.HttpStatus.NOT_FOUND; + +import org.springframework.http.HttpStatus; + import lombok.AllArgsConstructor; import lombok.Getter; @Getter @AllArgsConstructor public enum ErrorCode { + + /* 404 NOT_FOUND : 자원을 찾을 수 없음 */ + INVALID_FOLDER(NOT_FOUND, "유효하지 않은 폴더입니다."); + + private final HttpStatus httpStatus; + private final String message; } From 2e8ab3547b498a6c5346554000a6bd48a4e6f47e Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:57:34 +0900 Subject: [PATCH 12/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=84=B1?= =?UTF-8?q?=EA=B3=B5=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/message/SuccessMessage.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/message/SuccessMessage.java diff --git a/src/main/java/com/tiki/server/folder/message/SuccessMessage.java b/src/main/java/com/tiki/server/folder/message/SuccessMessage.java new file mode 100644 index 00000000..1a82e040 --- /dev/null +++ b/src/main/java/com/tiki/server/folder/message/SuccessMessage.java @@ -0,0 +1,9 @@ +package com.tiki.server.folder.message; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum SuccessMessage { +} From b5845e9cfa1e59ebdfa9ee271703e33985a1669b Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:57:49 +0900 Subject: [PATCH 13/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=84=B1=EA=B3=B5=20=EB=A9=94=EC=84=B8=EC=A7=80=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 --- .../java/com/tiki/server/folder/message/SuccessMessage.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/folder/message/SuccessMessage.java b/src/main/java/com/tiki/server/folder/message/SuccessMessage.java index 1a82e040..c17acae0 100644 --- a/src/main/java/com/tiki/server/folder/message/SuccessMessage.java +++ b/src/main/java/com/tiki/server/folder/message/SuccessMessage.java @@ -6,4 +6,8 @@ @Getter @RequiredArgsConstructor public enum SuccessMessage { + + SUCCESS_CREATE_FOLDER("폴더 생성 성공"); + + private final String message; } From 5ac80d82e733fb7a5ff3552fb0424551be1736c1 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:58:18 +0900 Subject: [PATCH 14/20] =?UTF-8?q?[INIT]=20=ED=8F=B4=EB=8D=94=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/folder/exception/FolderException.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/exception/FolderException.java diff --git a/src/main/java/com/tiki/server/folder/exception/FolderException.java b/src/main/java/com/tiki/server/folder/exception/FolderException.java new file mode 100644 index 00000000..9f8cca7d --- /dev/null +++ b/src/main/java/com/tiki/server/folder/exception/FolderException.java @@ -0,0 +1,16 @@ +package com.tiki.server.folder.exception; + +import com.tiki.server.folder.message.ErrorCode; + +import lombok.Getter; + +@Getter +public class FolderException extends RuntimeException { + + private final ErrorCode errorCode; + + public FolderException(ErrorCode errorCode) { + super("[FolderException] : " + errorCode.getMessage()); + this.errorCode = errorCode; + } +} From 229771d183edf25e8326c8a5bc722f0a0216cbff Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:59:00 +0900 Subject: [PATCH 15/20] =?UTF-8?q?[INIT]=20=ED=8F=B4=EB=8D=94=20=ED=83=90?= =?UTF-8?q?=EC=83=89=EA=B8=B0=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/folder/adapter/FolderFinder.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/adapter/FolderFinder.java diff --git a/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java new file mode 100644 index 00000000..31eb06cc --- /dev/null +++ b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java @@ -0,0 +1,13 @@ +package com.tiki.server.folder.adapter; + +import com.tiki.server.common.support.RepositoryAdapter; +import com.tiki.server.folder.repository.FolderRepository; + +import lombok.RequiredArgsConstructor; + +@RepositoryAdapter +@RequiredArgsConstructor +public class FolderFinder { + + private final FolderRepository folderRepository; +} From dae655aba3dd0b8a57f530926955034f5fb1dfc1 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:59:11 +0900 Subject: [PATCH 16/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/adapter/FolderFinder.java | 9 +++++++++ 1 file changed, 9 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 31eb06cc..57cf63bb 100644 --- a/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java +++ b/src/main/java/com/tiki/server/folder/adapter/FolderFinder.java @@ -1,6 +1,10 @@ package com.tiki.server.folder.adapter; +import static com.tiki.server.folder.message.ErrorCode.INVALID_FOLDER; + import com.tiki.server.common.support.RepositoryAdapter; +import com.tiki.server.folder.entity.Folder; +import com.tiki.server.folder.exception.FolderException; import com.tiki.server.folder.repository.FolderRepository; import lombok.RequiredArgsConstructor; @@ -10,4 +14,9 @@ public class FolderFinder { private final FolderRepository folderRepository; + + public Folder findById(long id) { + return folderRepository.findById(id) + .orElseThrow(() -> new FolderException(INVALID_FOLDER)); + } } From 499f304b4242902a67fb4c2c647fbca70ee571e7 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:59:36 +0900 Subject: [PATCH 17/20] =?UTF-8?q?[INIT]=20=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EA=B8=B0=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/folder/adapter/FolderSaver.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/tiki/server/folder/adapter/FolderSaver.java diff --git a/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java b/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java new file mode 100644 index 00000000..b582e717 --- /dev/null +++ b/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java @@ -0,0 +1,13 @@ +package com.tiki.server.folder.adapter; + +import com.tiki.server.common.support.RepositoryAdapter; +import com.tiki.server.folder.repository.FolderRepository; + +import lombok.RequiredArgsConstructor; + +@RepositoryAdapter +@RequiredArgsConstructor +public class FolderSaver { + + private final FolderRepository folderRepository; +} From dcfb33fa7faf5ce599ccaf5a29aa107f445ed167 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 19:59:49 +0900 Subject: [PATCH 18/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/folder/adapter/FolderSaver.java | 5 +++++ 1 file changed, 5 insertions(+) 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 b582e717..c00db2b5 100644 --- a/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java +++ b/src/main/java/com/tiki/server/folder/adapter/FolderSaver.java @@ -1,6 +1,7 @@ package com.tiki.server.folder.adapter; import com.tiki.server.common.support.RepositoryAdapter; +import com.tiki.server.folder.entity.Folder; import com.tiki.server.folder.repository.FolderRepository; import lombok.RequiredArgsConstructor; @@ -10,4 +11,8 @@ public class FolderSaver { private final FolderRepository folderRepository; + + public Folder save(Folder folder) { + return folderRepository.save(folder); + } } From e9ac14693706f8e93993b3b7ab513ff2dca2820a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 20:02:59 +0900 Subject: [PATCH 19/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/folder/service/FolderService.java | 26 +++++++++++++++++-- 1 file changed, 24 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 9a7e2cab..6b084a6d 100644 --- a/src/main/java/com/tiki/server/folder/service/FolderService.java +++ b/src/main/java/com/tiki/server/folder/service/FolderService.java @@ -3,7 +3,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.tiki.server.folder.repository.FolderRepository; +import com.tiki.server.folder.adapter.FolderFinder; +import com.tiki.server.folder.adapter.FolderSaver; +import com.tiki.server.folder.dto.request.FolderCreateRequest; +import com.tiki.server.folder.dto.response.FolderCreateResponse; +import com.tiki.server.folder.entity.Folder; +import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; import lombok.RequiredArgsConstructor; @@ -12,6 +17,23 @@ @Transactional(readOnly = true) public class FolderService { - private final FolderRepository folderRepository; + private final FolderFinder folderFinder; + private final FolderSaver folderSaver; + private final MemberTeamManagerFinder memberTeamManagerFinder; + @Transactional + public FolderCreateResponse create(long memberId, long teamId, FolderCreateRequest request) { + // 같은 레벨 파일명 중복 방지 로직 추가 필요 + memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + Folder parentFolder = getFolder(request.parentId()); + Folder folder = folderSaver.save(new Folder(request.name(), parentFolder, teamId)); + return FolderCreateResponse.from(folder.getId()); + } + + private Folder getFolder(Long folderId) { + if (folderId == null) { + return null; + } + return folderFinder.findById(folderId); + } } From 004f979948ed392e28dbd9ff7185f58b9ca172d3 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 24 Oct 2024 20:03:11 +0900 Subject: [PATCH 20/20] =?UTF-8?q?[FEAT]=20=ED=8F=B4=EB=8D=94=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../folder/controller/FolderController.java | 27 ++++++++++++++++--- 1 file changed, 24 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 de4aacd1..fe2837e5 100644 --- a/src/main/java/com/tiki/server/folder/controller/FolderController.java +++ b/src/main/java/com/tiki/server/folder/controller/FolderController.java @@ -1,8 +1,21 @@ package com.tiki.server.folder.controller; +import static com.tiki.server.common.dto.SuccessResponse.*; +import static com.tiki.server.folder.message.SuccessMessage.SUCCESS_CREATE_FOLDER; + +import java.security.Principal; + +import org.springframework.http.ResponseEntity; +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.RestController; +import com.tiki.server.common.dto.SuccessResponse; +import com.tiki.server.common.support.UriGenerator; +import com.tiki.server.folder.dto.request.FolderCreateRequest; +import com.tiki.server.folder.dto.response.FolderCreateResponse; import com.tiki.server.folder.service.FolderService; import lombok.RequiredArgsConstructor; @@ -14,7 +27,15 @@ public class FolderController { private final FolderService folderService; - /* - 폴더 생성하기 - */ + @PostMapping() + public ResponseEntity> createFolder( + Principal principal, + @RequestHeader("team-id") long teamId, + @RequestBody FolderCreateRequest request + ) { + long memberId = Long.parseLong(principal.getName()); + FolderCreateResponse response = folderService.create(memberId, teamId, request); + return ResponseEntity.created(UriGenerator.getUri("api/v2/folders/" + response.folderId())) + .body(success(SUCCESS_CREATE_FOLDER.getMessage(), response)); + } }