From 4e101570824656524c57ea0266da387770c9d1e0 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:37:12 +0900 Subject: [PATCH 01/65] =?UTF-8?q?feat(TimeBlockCreateRequest):=20=ED=83=80?= =?UTF-8?q?=EC=9E=84=20=EB=B8=94=EB=A1=9D=20=EC=83=9D=EC=84=B1=20dto=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 파일 id 리스트를 받도록 수정 --- .../server/timeblock/dto/request/TimeBlockCreateRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/dto/request/TimeBlockCreateRequest.java b/src/main/java/com/tiki/server/timeblock/dto/request/TimeBlockCreateRequest.java index 3a619105..c25e9c6c 100644 --- a/src/main/java/com/tiki/server/timeblock/dto/request/TimeBlockCreateRequest.java +++ b/src/main/java/com/tiki/server/timeblock/dto/request/TimeBlockCreateRequest.java @@ -1,7 +1,7 @@ package com.tiki.server.timeblock.dto.request; import java.time.LocalDate; -import java.util.Map; +import java.util.List; import com.tiki.server.timeblock.entity.BlockType; @@ -13,6 +13,6 @@ public record TimeBlockCreateRequest( @NonNull LocalDate startDate, @NonNull LocalDate endDate, @NonNull BlockType blockType, - Map files + List documentIds ) { } From cf277e42ef68835330ba750d7cde95f40638afb3 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:38:57 +0900 Subject: [PATCH 02/65] =?UTF-8?q?chore(TimeBlockService):=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 --- .../timeblock/service/TimeBlockService.java | 139 ++++++++++-------- 1 file changed, 77 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 66169dd6..b5243b56 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -7,6 +7,7 @@ import com.tiki.server.note.entity.Note; import com.tiki.server.notetimeblockmanager.adapter.NoteTimeBlockManagerFinder; import com.tiki.server.notetimeblockmanager.entity.NoteTimeBlockManager; + import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,6 +29,7 @@ import com.tiki.server.timeblock.dto.response.TimeBlockDetailGetResponse; import com.tiki.server.timeblock.dto.response.TimelineGetResponse; import com.tiki.server.timeblock.entity.TimeBlock; + import lombok.RequiredArgsConstructor; @Service @@ -35,73 +37,86 @@ @Transactional(readOnly = true) public class TimeBlockService { - private final TeamFinder teamFinder; - private final MemberTeamManagerFinder memberTeamManagerFinder; - private final TimeBlockSaver timeBlockSaver; - private final TimeBlockFinder timeBlockFinder; - private final TimeBlockDeleter timeBlockDeleter; - private final DocumentSaver documentSaver; - private final DocumentFinder documentFinder; - private final DocumentDeleter documentDeleter; - private final NoteTimeBlockManagerFinder noteTimeBlockManagerFinder; - private final NoteFinder noteFinder; + private final TeamFinder teamFinder; + private final MemberTeamManagerFinder memberTeamManagerFinder; + private final TimeBlockSaver timeBlockSaver; + private final TimeBlockFinder timeBlockFinder; + private final TimeBlockDeleter timeBlockDeleter; + private final DocumentSaver documentSaver; + private final DocumentFinder documentFinder; + private final DocumentDeleter documentDeleter; + private final NoteTimeBlockManagerFinder noteTimeBlockManagerFinder; + private final NoteFinder noteFinder; - @Transactional - public TimeBlockCreateResponse createTimeBlock( - long memberId, - long teamId, - String type, - TimeBlockCreateRequest request - ) { - Team team = teamFinder.findById(teamId); - MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - Position accessiblePosition = Position.getAccessiblePosition(type); - memberTeamManager.checkMemberAccessible(accessiblePosition); - TimeBlock timeBlock = saveTimeBlock(team, accessiblePosition, request); - saveDocuments(request.files(), timeBlock); - return TimeBlockCreateResponse.of(timeBlock.getId()); - } + @Transactional + public TimeBlockCreateResponse createTimeBlock( + final long memberId, + final long teamId, + final String type, + final TimeBlockCreateRequest request + ) { + Team team = teamFinder.findById(teamId); + MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + Position accessiblePosition = Position.getAccessiblePosition(type); + memberTeamManager.checkMemberAccessible(accessiblePosition); + TimeBlock timeBlock = saveTimeBlock(team, accessiblePosition, request); + saveDocuments(request.files(), timeBlock); + return TimeBlockCreateResponse.of(timeBlock.getId()); + } - public TimelineGetResponse getTimeline(long memberId, long teamId, String type, String date) { - Team team = teamFinder.findById(teamId); - MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - Position accessiblePosition = Position.getAccessiblePosition(type); - memberTeamManager.checkMemberAccessible(accessiblePosition); - List timeBlocks = timeBlockFinder.findByTeamAndAccessiblePositionAndDate( - team.getId(), accessiblePosition.name(), date); - return TimelineGetResponse.from(timeBlocks); - } + public TimelineGetResponse getTimeline( + final long memberId, + final long teamId, + final String type, + final String date + ) { + Team team = teamFinder.findById(teamId); + MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + Position accessiblePosition = Position.getAccessiblePosition(type); + memberTeamManager.checkMemberAccessible(accessiblePosition); + List timeBlocks = timeBlockFinder.findByTeamAndAccessiblePositionAndDate( + team.getId(), accessiblePosition.name(), date); + return TimelineGetResponse.from(timeBlocks); + } - public TimeBlockDetailGetResponse getTimeBlockDetail(long memberId, long teamId, long timeBlockId) { - MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - TimeBlock timeBlock = timeBlockFinder.findByIdOrElseThrow(timeBlockId); - memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); - List documents = documentFinder.findAllByTimeBlockId(timeBlockId); - List notes = getNotes(timeBlock.getId()); - return TimeBlockDetailGetResponse.from(documents, notes); - } + public TimeBlockDetailGetResponse getTimeBlockDetail( + final long memberId, + final long teamId, + final long timeBlockId + ) { + MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + TimeBlock timeBlock = timeBlockFinder.findByIdOrElseThrow(timeBlockId); + memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); + List documents = documentFinder.findAllByTimeBlockId(timeBlockId); + List notes = getNotes(timeBlock.getId()); + return TimeBlockDetailGetResponse.from(documents, notes); + } - @Transactional - public void deleteTimeBlock(long memberId, long teamId, long timeBlockId) { - MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - TimeBlock timeBlock = timeBlockFinder.findByIdOrElseThrow(timeBlockId); - memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); - documentDeleter.deleteAllByTimeBlockId(timeBlock.getId()); - timeBlockDeleter.deleteById(timeBlock.getId()); - } + @Transactional + public void deleteTimeBlock(final long memberId, final long teamId, final long timeBlockId) { + MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + TimeBlock timeBlock = timeBlockFinder.findByIdOrElseThrow(timeBlockId); + memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); + documentDeleter.deleteAllByTimeBlockId(timeBlock.getId()); + timeBlockDeleter.deleteById(timeBlock.getId()); + } - private TimeBlock saveTimeBlock(Team team, Position accessiblePosition, TimeBlockCreateRequest request) { - return timeBlockSaver.save(TimeBlock.of(team, accessiblePosition, request)); - } + private TimeBlock saveTimeBlock( + final Team team, + final Position accessiblePosition, + final TimeBlockCreateRequest request + ) { + return timeBlockSaver.save(TimeBlock.of(team, accessiblePosition, request)); + } - private void saveDocuments(Map files, TimeBlock timeBlock) { - files.forEach((fileName, fileUrl) -> documentSaver.save(Document.of(fileName, fileUrl, timeBlock))); - } + private void saveDocuments(final Map files, final TimeBlock timeBlock) { + files.forEach((fileName, fileUrl) -> documentSaver.save(Document.of(fileName, fileUrl, timeBlock))); + } - private List getNotes(final long timeBlockId) { - List noteTimeBlockManagers = noteTimeBlockManagerFinder.findAllByTimeBlockId(timeBlockId); - return noteTimeBlockManagers.stream() - .map(noteTimeBlockManager -> noteFinder.findById(noteTimeBlockManager.getNoteId())) - .toList(); - } + private List getNotes(final long timeBlockId) { + List noteTimeBlockManagers = noteTimeBlockManagerFinder.findAllByTimeBlockId(timeBlockId); + return noteTimeBlockManagers.stream() + .map(noteTimeBlockManager -> noteFinder.findById(noteTimeBlockManager.getNoteId())) + .toList(); + } } From 9ae2d912aaa044fa5bf58207ece640f01c77b732 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:42:42 +0900 Subject: [PATCH 03/65] =?UTF-8?q?feat(TimeBlockService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20id=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=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/timeblock/service/TimeBlockService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index b5243b56..fe8b7b56 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -59,6 +59,7 @@ public TimeBlockCreateResponse createTimeBlock( MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); Position accessiblePosition = Position.getAccessiblePosition(type); memberTeamManager.checkMemberAccessible(accessiblePosition); + validateDocuments(team, request.documentIds()); TimeBlock timeBlock = saveTimeBlock(team, accessiblePosition, request); saveDocuments(request.files(), timeBlock); return TimeBlockCreateResponse.of(timeBlock.getId()); @@ -101,6 +102,10 @@ public void deleteTimeBlock(final long memberId, final long teamId, final long t timeBlockDeleter.deleteById(timeBlock.getId()); } + private void validateDocuments(final Team team, final List documentIds) { + documentFinder.findAllByIdAndTeamId(documentIds, team.getId()); + } + private TimeBlock saveTimeBlock( final Team team, final Position accessiblePosition, From 1ec6fcebd29a02199c2984a5451cf17550189ea7 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:43:18 +0900 Subject: [PATCH 04/65] =?UTF-8?q?delete(TimeBlockService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=83=9D=EC=84=B1=20=EB=A9=94=EC=86=8C=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/timeblock/service/TimeBlockService.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index fe8b7b56..c2c6822d 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -61,7 +61,6 @@ public TimeBlockCreateResponse createTimeBlock( memberTeamManager.checkMemberAccessible(accessiblePosition); validateDocuments(team, request.documentIds()); TimeBlock timeBlock = saveTimeBlock(team, accessiblePosition, request); - saveDocuments(request.files(), timeBlock); return TimeBlockCreateResponse.of(timeBlock.getId()); } @@ -114,10 +113,6 @@ private TimeBlock saveTimeBlock( return timeBlockSaver.save(TimeBlock.of(team, accessiblePosition, request)); } - private void saveDocuments(final Map files, final TimeBlock timeBlock) { - files.forEach((fileName, fileUrl) -> documentSaver.save(Document.of(fileName, fileUrl, timeBlock))); - } - private List getNotes(final long timeBlockId) { List noteTimeBlockManagers = noteTimeBlockManagerFinder.findAllByTimeBlockId(timeBlockId); return noteTimeBlockManagers.stream() From 07ca8e81d4e1d3ec725170dd6458863ec3e5cd2b Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:44:07 +0900 Subject: [PATCH 05/65] =?UTF-8?q?style(TimeBlockService):=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 --- .../com/tiki/server/timeblock/service/TimeBlockService.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index c2c6822d..bb7c35ce 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -1,7 +1,6 @@ package com.tiki.server.timeblock.service; import java.util.List; -import java.util.Map; import com.tiki.server.note.adapter.NoteFinder; import com.tiki.server.note.entity.Note; @@ -14,8 +13,6 @@ import com.tiki.server.common.entity.Position; import com.tiki.server.document.adapter.DocumentDeleter; import com.tiki.server.document.adapter.DocumentFinder; -import com.tiki.server.document.adapter.DocumentSaver; -import com.tiki.server.document.entity.Document; import com.tiki.server.document.vo.DocumentVO; import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; import com.tiki.server.memberteammanager.entity.MemberTeamManager; @@ -42,7 +39,6 @@ public class TimeBlockService { private final TimeBlockSaver timeBlockSaver; private final TimeBlockFinder timeBlockFinder; private final TimeBlockDeleter timeBlockDeleter; - private final DocumentSaver documentSaver; private final DocumentFinder documentFinder; private final DocumentDeleter documentDeleter; private final NoteTimeBlockManagerFinder noteTimeBlockManagerFinder; From 902d226c5d44adb7dbbba4f56b18f1c258393582 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:47:16 +0900 Subject: [PATCH 06/65] =?UTF-8?q?feat(DTBManager):=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=83=80=EC=9E=84=EB=B8=94=EB=A1=9D=20=EB=8B=A4=EB=8C=80?= =?UTF-8?q?=EB=8B=A4=20=ED=85=8C=EC=9D=B4=EB=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/DTBManager.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java b/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java new file mode 100644 index 00000000..c1ca3e41 --- /dev/null +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java @@ -0,0 +1,39 @@ +package com.tiki.server.documenttimeblockmanager.entity; + +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PRIVATE; +import static lombok.AccessLevel.PROTECTED; + +import com.tiki.server.common.entity.BaseTime; +import com.tiki.server.timeblock.entity.TimeBlock; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; + +@Entity +@Builder(access = PRIVATE) +@AllArgsConstructor(access = PRIVATE) +@NoArgsConstructor(access = PROTECTED) +@Table(name = "document_time_block_manager") +public class DTBManager extends BaseTime { + + @Id + @GeneratedValue(strategy = IDENTITY) + private Long id; + + private long documentId; + + private long timeBlockId; + + public static DTBManager of(final TimeBlock timeBlock, final long documentId) { + return DTBManager.builder() + .documentId(documentId) + .timeBlockId(timeBlock.getId()) + .build(); + } +} From 68c4e0f2cdb70e9a1774c043ed15d5e468a6c71d Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:47:59 +0900 Subject: [PATCH 07/65] =?UTF-8?q?feat(DTBRepository):=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=ED=83=80=EC=9E=84=20=EB=B8=94=EB=A1=9D=20=EB=A6=AC=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 --- .../repository/DTBRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java new file mode 100644 index 00000000..566d062d --- /dev/null +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java @@ -0,0 +1,8 @@ +package com.tiki.server.documenttimeblockmanager.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.tiki.server.documenttimeblockmanager.entity.DTBManager; + +public interface DTBRepository extends JpaRepository { +} From 7d04e4e1a0cb18342900f40d2b8f145352771b64 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:48:20 +0900 Subject: [PATCH 08/65] =?UTF-8?q?feat(DTBAdapter):=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=83=80=EC=9E=84=20=EB=B8=94=EB=A1=9D=20=EA=B4=80=EA=B3=84=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/DTBAdapter.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java new file mode 100644 index 00000000..ea2675af --- /dev/null +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java @@ -0,0 +1,21 @@ +package com.tiki.server.documenttimeblockmanager.adapter; + +import java.util.List; + +import com.tiki.server.common.support.RepositoryAdapter; +import com.tiki.server.documenttimeblockmanager.entity.DTBManager; +import com.tiki.server.documenttimeblockmanager.repository.DTBRepository; +import com.tiki.server.timeblock.entity.TimeBlock; + +import lombok.RequiredArgsConstructor; + +@RepositoryAdapter +@RequiredArgsConstructor +public class DTBAdapter { + + private final DTBRepository dtbRepository; + + public void saveAll(final TimeBlock timeBlock, final List documentIds) { + documentIds.forEach(documentId -> dtbRepository.save(DTBManager.of(timeBlock, documentId))); + } +} From b0c261a8b989014df0f1e099a57b9bbf9efc3b6d Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:49:54 +0900 Subject: [PATCH 09/65] =?UTF-8?q?chore(TimeBlockController):=20RequestMapp?= =?UTF-8?q?ing=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit url 변동 x --- .../timeblock/controller/TimeBlockController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java index 50ed73bd..b41a82c7 100644 --- a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java +++ b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java @@ -30,13 +30,13 @@ @RestController @RequiredArgsConstructor -@RequestMapping("api/v1/time-blocks") +@RequestMapping("api/v1") public class TimeBlockController implements TimeBlockControllerDocs { private final TimeBlockService timeBlockService; @Override - @PostMapping("/team/{teamId}/time-block") + @PostMapping("/time-blocks/team/{teamId}/time-block") public ResponseEntity> createTimeBlock( Principal principal, @PathVariable long teamId, @@ -51,7 +51,7 @@ public ResponseEntity> createTimeBlock( } @Override - @GetMapping("/team/{teamId}/timeline") + @GetMapping("/time-blocks/team/{teamId}/timeline") public ResponseEntity> getTimeline( Principal principal, @PathVariable long teamId, @@ -64,7 +64,7 @@ public ResponseEntity> getTimeline( } @Override - @GetMapping("/team/{teamId}/time-block/{timeBlockId}") + @GetMapping("/time-blocks/team/{teamId}/time-block/{timeBlockId}") public ResponseEntity> getTimeBlockDetail( Principal principal, @PathVariable long teamId, @@ -76,7 +76,7 @@ public ResponseEntity> getTimeBlockD } @Override - @DeleteMapping("/team/{teamId}/time-block/{timeBlockId}") + @DeleteMapping("/time-blocks/team/{teamId}/time-block/{timeBlockId}") public ResponseEntity deleteTimeBlock( Principal principal, @PathVariable long teamId, From 8e49b70b13dcd81efcf469ba3e28315d634d5d74 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:50:52 +0900 Subject: [PATCH 10/65] =?UTF-8?q?feat(TimeBlockService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=80=EC=9E=84=20=EB=B8=94=EB=A1=9D=20=EA=B4=80?= =?UTF-8?q?=EA=B3=84=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/timeblock/service/TimeBlockService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index bb7c35ce..3d3f292f 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -2,6 +2,7 @@ import java.util.List; +import com.tiki.server.documenttimeblockmanager.adapter.DTBAdapter; import com.tiki.server.note.adapter.NoteFinder; import com.tiki.server.note.entity.Note; import com.tiki.server.notetimeblockmanager.adapter.NoteTimeBlockManagerFinder; @@ -41,6 +42,7 @@ public class TimeBlockService { private final TimeBlockDeleter timeBlockDeleter; private final DocumentFinder documentFinder; private final DocumentDeleter documentDeleter; + private final DTBAdapter dtbAdapter; private final NoteTimeBlockManagerFinder noteTimeBlockManagerFinder; private final NoteFinder noteFinder; @@ -57,6 +59,7 @@ public TimeBlockCreateResponse createTimeBlock( memberTeamManager.checkMemberAccessible(accessiblePosition); validateDocuments(team, request.documentIds()); TimeBlock timeBlock = saveTimeBlock(team, accessiblePosition, request); + dtbAdapter.saveAll(timeBlock, request.documentIds()); return TimeBlockCreateResponse.of(timeBlock.getId()); } From 1a45938cb7ba0e4080d952b9c8d18047ec1240bf Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:54:44 +0900 Subject: [PATCH 11/65] =?UTF-8?q?chore(TimeBlockController):=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/TimeBlockController.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java index b41a82c7..b9a87aa9 100644 --- a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java +++ b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java @@ -38,10 +38,10 @@ public class TimeBlockController implements TimeBlockControllerDocs { @Override @PostMapping("/time-blocks/team/{teamId}/time-block") public ResponseEntity> createTimeBlock( - Principal principal, - @PathVariable long teamId, - @RequestParam String type, - @RequestBody TimeBlockCreateRequest request + final Principal principal, + @PathVariable final long teamId, + @RequestParam final String type, + @RequestBody final TimeBlockCreateRequest request ) { long memberId = Long.parseLong(principal.getName()); TimeBlockCreateResponse response = timeBlockService.createTimeBlock(memberId, teamId, type, request); @@ -53,10 +53,10 @@ public ResponseEntity> createTimeBlock( @Override @GetMapping("/time-blocks/team/{teamId}/timeline") public ResponseEntity> getTimeline( - Principal principal, - @PathVariable long teamId, - @RequestParam String type, - @RequestParam String date + final Principal principal, + @PathVariable final long teamId, + @RequestParam final String type, + @RequestParam final String date ) { long memberId = Long.parseLong(principal.getName()); TimelineGetResponse response = timeBlockService.getTimeline(memberId, teamId, type, date); @@ -66,9 +66,9 @@ public ResponseEntity> getTimeline( @Override @GetMapping("/time-blocks/team/{teamId}/time-block/{timeBlockId}") public ResponseEntity> getTimeBlockDetail( - Principal principal, - @PathVariable long teamId, - @PathVariable long timeBlockId + final Principal principal, + @PathVariable final long teamId, + @PathVariable final long timeBlockId ) { long memberId = Long.parseLong(principal.getName()); TimeBlockDetailGetResponse response = timeBlockService.getTimeBlockDetail(memberId, teamId, timeBlockId); @@ -78,9 +78,9 @@ public ResponseEntity> getTimeBlockD @Override @DeleteMapping("/time-blocks/team/{teamId}/time-block/{timeBlockId}") public ResponseEntity deleteTimeBlock( - Principal principal, - @PathVariable long teamId, - @PathVariable long timeBlockId + final Principal principal, + @PathVariable final long teamId, + @PathVariable final long timeBlockId ) { long memberId = Long.parseLong(principal.getName()); timeBlockService.deleteTimeBlock(memberId, teamId, timeBlockId); From f34589f00ae71244138dd6628dab1a0aab1290df Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:56:59 +0900 Subject: [PATCH 12/65] =?UTF-8?q?refactor(TimeBlockController):=20url=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 --- .../server/timeblock/controller/TimeBlockController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java index b9a87aa9..753b0bc3 100644 --- a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java +++ b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java @@ -36,7 +36,7 @@ public class TimeBlockController implements TimeBlockControllerDocs { private final TimeBlockService timeBlockService; @Override - @PostMapping("/time-blocks/team/{teamId}/time-block") + @PostMapping("/teams/{teamId}/time-block") public ResponseEntity> createTimeBlock( final Principal principal, @PathVariable final long teamId, @@ -51,7 +51,7 @@ public ResponseEntity> createTimeBlock( } @Override - @GetMapping("/time-blocks/team/{teamId}/timeline") + @GetMapping("/teams/{teamId}/timeline") public ResponseEntity> getTimeline( final Principal principal, @PathVariable final long teamId, @@ -64,7 +64,7 @@ public ResponseEntity> getTimeline( } @Override - @GetMapping("/time-blocks/team/{teamId}/time-block/{timeBlockId}") + @GetMapping("/teams/{teamId}/time-block/{timeBlockId}") public ResponseEntity> getTimeBlockDetail( final Principal principal, @PathVariable final long teamId, @@ -76,7 +76,7 @@ public ResponseEntity> getTimeBlockD } @Override - @DeleteMapping("/time-blocks/team/{teamId}/time-block/{timeBlockId}") + @DeleteMapping("/teams/{teamId}/time-block/{timeBlockId}") public ResponseEntity deleteTimeBlock( final Principal principal, @PathVariable final long teamId, From dd7981a2817d060caa5a348e7e6c77605f89ecec Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:58:03 +0900 Subject: [PATCH 13/65] =?UTF-8?q?refactor:=20=EB=A9=94=EC=86=8C=EB=93=9C?= =?UTF-8?q?=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 orElseThrow 제거 --- .../tiki/server/note/service/NoteService.java | 2 +- .../timeblock/adapter/TimeBlockFinder.java | 38 +++++++++---------- .../timeblock/service/TimeBlockService.java | 4 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/tiki/server/note/service/NoteService.java b/src/main/java/com/tiki/server/note/service/NoteService.java index a9be7efc..df691ab2 100644 --- a/src/main/java/com/tiki/server/note/service/NoteService.java +++ b/src/main/java/com/tiki/server/note/service/NoteService.java @@ -201,7 +201,7 @@ private List getTimeBlocksMappedByNote(final long noteId) { .map(NoteTimeBlockManager::getTimeBlockId) .toList(); return timblockIdList.stream() - .map(timeBlockFinder::findByIdOrElseThrow) + .map(timeBlockFinder::findById) .toList(); } diff --git a/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java b/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java index a87d2e76..eb9bb185 100644 --- a/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java +++ b/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java @@ -15,23 +15,23 @@ @RequiredArgsConstructor public class TimeBlockFinder { - private final TimeBlockRepository timeBlockRepository; - - public TimeBlock findByIdOrElseThrow(long id) { - return timeBlockRepository.findById(id) - .orElseThrow(() -> new TimeBlockException(INVALID_TIME_BLOCK)); - } - - public List findByTeamAndAccessiblePositionAndDate( - long teamId, - String accessiblePosition, - String date - ) { - return timeBlockRepository. - findByTeamAndAccessiblePositionAndDate(teamId, accessiblePosition, date).stream().toList(); - } - - public boolean existsById(Long timeBlockId) { - return timeBlockRepository.existsById(timeBlockId); - } + private final TimeBlockRepository timeBlockRepository; + + public TimeBlock findById(long id) { + return timeBlockRepository.findById(id) + .orElseThrow(() -> new TimeBlockException(INVALID_TIME_BLOCK)); + } + + public List findByTeamAndAccessiblePositionAndDate( + long teamId, + String accessiblePosition, + String date + ) { + return timeBlockRepository. + findByTeamAndAccessiblePositionAndDate(teamId, accessiblePosition, date).stream().toList(); + } + + public boolean existsById(Long timeBlockId) { + return timeBlockRepository.existsById(timeBlockId); + } } diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 3d3f292f..c02d081a 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -84,7 +84,7 @@ public TimeBlockDetailGetResponse getTimeBlockDetail( final long timeBlockId ) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - TimeBlock timeBlock = timeBlockFinder.findByIdOrElseThrow(timeBlockId); + TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); List documents = documentFinder.findAllByTimeBlockId(timeBlockId); List notes = getNotes(timeBlock.getId()); @@ -94,7 +94,7 @@ public TimeBlockDetailGetResponse getTimeBlockDetail( @Transactional public void deleteTimeBlock(final long memberId, final long teamId, final long timeBlockId) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - TimeBlock timeBlock = timeBlockFinder.findByIdOrElseThrow(timeBlockId); + TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); documentDeleter.deleteAllByTimeBlockId(timeBlock.getId()); timeBlockDeleter.deleteById(timeBlock.getId()); From 734229c319b0c5fafe4dda7f5b01df6cc278b87c Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 17:59:07 +0900 Subject: [PATCH 14/65] =?UTF-8?q?chore(TimeBlockFinder):=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/timeblock/adapter/TimeBlockFinder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java b/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java index eb9bb185..af1fce66 100644 --- a/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java +++ b/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java @@ -17,18 +17,18 @@ public class TimeBlockFinder { private final TimeBlockRepository timeBlockRepository; - public TimeBlock findById(long id) { + public TimeBlock findById(final long id) { return timeBlockRepository.findById(id) .orElseThrow(() -> new TimeBlockException(INVALID_TIME_BLOCK)); } public List findByTeamAndAccessiblePositionAndDate( - long teamId, - String accessiblePosition, - String date + final long teamId, + final String accessiblePosition, + final String date ) { - return timeBlockRepository. - findByTeamAndAccessiblePositionAndDate(teamId, accessiblePosition, date).stream().toList(); + return timeBlockRepository.findByTeamAndAccessiblePositionAndDate(teamId, accessiblePosition, date).stream() + .toList(); } public boolean existsById(Long timeBlockId) { From 7578c1b468b96a3ad92d1533a217d9f885559ffc Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:00:46 +0900 Subject: [PATCH 15/65] =?UTF-8?q?feat(DTBRepository):=20=ED=83=80=EC=9E=84?= =?UTF-8?q?=20=EB=B8=94=EB=A1=9D=EA=B3=BC=20=EC=97=B0=EA=B4=80=EB=90=9C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../documenttimeblockmanager/repository/DTBRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java index 566d062d..9a6e5d1c 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java @@ -5,4 +5,5 @@ import com.tiki.server.documenttimeblockmanager.entity.DTBManager; public interface DTBRepository extends JpaRepository { + void deleteAllByTimeBlockId(long timeBlockId); } From c2a3c2c27c7e0ebfa5b3e86fb3224d1989e1c7b3 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:01:01 +0900 Subject: [PATCH 16/65] =?UTF-8?q?feat(DTBAdapter):=20=ED=83=80=EC=9E=84=20?= =?UTF-8?q?=EB=B8=94=EB=A1=9D=EA=B3=BC=20=EC=97=B0=EA=B4=80=EB=90=9C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/documenttimeblockmanager/adapter/DTBAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java index ea2675af..3dc99b7b 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java @@ -18,4 +18,8 @@ public class DTBAdapter { public void saveAll(final TimeBlock timeBlock, final List documentIds) { documentIds.forEach(documentId -> dtbRepository.save(DTBManager.of(timeBlock, documentId))); } + + public void deleteAll(final TimeBlock timeBlock) { + dtbRepository.deleteAllByTimeBlockId(timeBlock.getId()); + } } From 453ee555c9a19ff9f1e0e7104a2ab6edb6525a65 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:02:08 +0900 Subject: [PATCH 17/65] =?UTF-8?q?delete(TimeBlockService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81=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/timeblock/service/TimeBlockService.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index c02d081a..90ce7356 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -12,7 +12,6 @@ import org.springframework.transaction.annotation.Transactional; import com.tiki.server.common.entity.Position; -import com.tiki.server.document.adapter.DocumentDeleter; import com.tiki.server.document.adapter.DocumentFinder; import com.tiki.server.document.vo.DocumentVO; import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; @@ -41,7 +40,6 @@ public class TimeBlockService { private final TimeBlockFinder timeBlockFinder; private final TimeBlockDeleter timeBlockDeleter; private final DocumentFinder documentFinder; - private final DocumentDeleter documentDeleter; private final DTBAdapter dtbAdapter; private final NoteTimeBlockManagerFinder noteTimeBlockManagerFinder; private final NoteFinder noteFinder; @@ -96,7 +94,6 @@ public void deleteTimeBlock(final long memberId, final long teamId, final long t MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); - documentDeleter.deleteAllByTimeBlockId(timeBlock.getId()); timeBlockDeleter.deleteById(timeBlock.getId()); } From 516e9392eadb2eb3800f63e7f313da8e068fe1a5 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:02:36 +0900 Subject: [PATCH 18/65] =?UTF-8?q?feat(TimeBlockService):=20=ED=83=80?= =?UTF-8?q?=EC=9E=84=20=EB=B8=94=EB=A1=9D=EA=B3=BC=20=EC=97=B0=EA=B4=80?= =?UTF-8?q?=EB=90=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tiki/server/timeblock/service/TimeBlockService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 90ce7356..3d00a865 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -94,6 +94,7 @@ public void deleteTimeBlock(final long memberId, final long teamId, final long t MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); + dtbAdapter.deleteAll(timeBlock); timeBlockDeleter.deleteById(timeBlock.getId()); } From 1e77ee9c10c34a1337529682d8a0193d92b16492 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:13:32 +0900 Subject: [PATCH 19/65] =?UTF-8?q?refactor(DTBAdapter):=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 --- .../server/documenttimeblockmanager/adapter/DTBAdapter.java | 2 +- .../com/tiki/server/timeblock/service/TimeBlockService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java index 3dc99b7b..532eac59 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java @@ -19,7 +19,7 @@ public void saveAll(final TimeBlock timeBlock, final List documentIds) { documentIds.forEach(documentId -> dtbRepository.save(DTBManager.of(timeBlock, documentId))); } - public void deleteAll(final TimeBlock timeBlock) { + public void deleteAllByTimeBlock(final TimeBlock timeBlock) { dtbRepository.deleteAllByTimeBlockId(timeBlock.getId()); } } diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 3d00a865..a678f9ff 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -94,7 +94,7 @@ public void deleteTimeBlock(final long memberId, final long teamId, final long t MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); - dtbAdapter.deleteAll(timeBlock); + dtbAdapter.deleteAllByTimeBlock(timeBlock); timeBlockDeleter.deleteById(timeBlock.getId()); } From 2aa1184e68db3271fda20d9e3844767e73c9bb02 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:14:04 +0900 Subject: [PATCH 20/65] =?UTF-8?q?feat(DTBRepository):=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EA=B3=BC=20=EC=97=B0=EA=B4=80=EB=90=9C=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../documenttimeblockmanager/repository/DTBRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java index 9a6e5d1c..ecf480de 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java @@ -1,9 +1,13 @@ package com.tiki.server.documenttimeblockmanager.repository; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; import com.tiki.server.documenttimeblockmanager.entity.DTBManager; public interface DTBRepository extends JpaRepository { void deleteAllByTimeBlockId(long timeBlockId); + + void deleteAllByDocumentIdIn(List documentIds); } From a2bacdb8f8e0923cdd36a364008e119633615d3f Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:14:27 +0900 Subject: [PATCH 21/65] =?UTF-8?q?feat(DTBAdapter):=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EA=B3=BC=20=EC=97=B0=EA=B4=80=EB=90=9C=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/documenttimeblockmanager/adapter/DTBAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java index 532eac59..6faaece7 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java @@ -22,4 +22,8 @@ public void saveAll(final TimeBlock timeBlock, final List documentIds) { public void deleteAllByTimeBlock(final TimeBlock timeBlock) { dtbRepository.deleteAllByTimeBlockId(timeBlock.getId()); } + + public void deleteAllByDocuments(final List documentIds) { + dtbRepository.deleteAllByDocumentIdIn(documentIds); + } } From bb0f8cc63dddad9377871e6ddc48a341f04094b9 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:15:44 +0900 Subject: [PATCH 22/65] =?UTF-8?q?feat(DocumentService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EA=B3=BC=20=EC=97=B0=EA=B4=80=EB=90=9C=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81=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/document/service/DocumentService.java | 3 +++ 1 file changed, 3 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 3c863fa2..d5a01d38 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -19,6 +19,7 @@ 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.documenttimeblockmanager.adapter.DTBAdapter; import com.tiki.server.external.util.S3Handler; import com.tiki.server.folder.adapter.FolderFinder; import com.tiki.server.folder.entity.Folder; @@ -41,6 +42,7 @@ public class DocumentService { private final MemberTeamManagerFinder memberTeamManagerFinder; private final DeletedDocumentAdapter deletedDocumentAdapter; private final TeamFinder teamFinder; + private final DTBAdapter dtbAdapter; private final S3Handler s3Handler; public DocumentsGetResponse getAllDocuments(final long memberId, final long teamId, final String type) { @@ -77,6 +79,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.findByMemberIdAndTeamId(memberId, teamId); List documents = documentFinder.findAllByIdAndTeamId(documentIds, teamId); + dtbAdapter.deleteAllByDocuments(documentIds); deletedDocumentAdapter.save(documents); documentDeleter.deleteAll(documents); } From 700fac5267b4d7aec7280514d05401ea9023add4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:18:14 +0900 Subject: [PATCH 23/65] =?UTF-8?q?delete(Document):=20=ED=83=80=EC=9E=84=20?= =?UTF-8?q?=EB=B8=94=EB=A1=9D=20=EA=B4=80=EB=A0=A8=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=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/entity/Document.java | 17 ----------------- 1 file changed, 17 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 429f21b5..e6bd5e5a 100644 --- a/src/main/java/com/tiki/server/document/entity/Document.java +++ b/src/main/java/com/tiki/server/document/entity/Document.java @@ -42,21 +42,6 @@ public class Document extends BaseTime { private Long folderId; - @ManyToOne(fetch = LAZY) - @JoinColumn(name = "block_id") - private TimeBlock timeBlock; - - public static Document of(final String fileName, final String fileUrl, final TimeBlock timeBlock) { - return Document.builder() - .fileName(fileName) - .fileUrl(fileUrl) - .capacity(0) // TODO : 타임 블록 생성 api 수정 후 제거 예정 - .teamId(1) // TODO : 타임 블록 생성 api 수정 후 제거 예정 - .folderId(null) // TODO : 타임 블록 생성 api 수정 후 제거 예정 - .timeBlock(timeBlock) - .build(); - } - public static Document of(final DocumentCreateRequest request, final long teamId, final Long folderId) { return Document.builder() .fileName(request.fileName()) @@ -64,7 +49,6 @@ public static Document of(final DocumentCreateRequest request, final long teamId .capacity(request.capacity()) .teamId(teamId) .folderId(folderId) - .timeBlock(null) // TODO : 타임 블록 생성 api 수정 후 제거 예정 .build(); } @@ -76,7 +60,6 @@ public static Document restore(final String fileName, final String fileUrl, .capacity(capacity) .teamId(teamId) .folderId(null) - .timeBlock(null) .build(); } } From a32fb56f04efe14306ddcf2ede37ba51683dbb2a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:20:09 +0900 Subject: [PATCH 24/65] =?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=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=84=EC=8B=9C=20=EC=A3=BC=EC=84=9D=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= 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 d5a01d38..457002a8 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,7 @@ public DocumentsGetResponse getAllDocuments(final long memberId, final long team public void deleteDocument(final long memberId, final long teamId, final long documentId) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); Document document = documentFinder.findByIdWithTimeBlock(documentId); - memberTeamManager.checkMemberAccessible(document.getTimeBlock().getAccessiblePosition()); + // memberTeamManager.checkMemberAccessible(document.getTimeBlock().getAccessiblePosition()); documentDeleter.delete(document); } From 5f7f5b80f05d52b24ac850f26ad080f4e940043d Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:27:35 +0900 Subject: [PATCH 25/65] =?UTF-8?q?feat(DTBRepository):=20=ED=83=80=EC=9E=84?= =?UTF-8?q?=20=EB=B8=94=EB=A1=9D=EA=B3=BC=20=EC=97=B0=EA=B4=80=EB=90=9C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../documenttimeblockmanager/repository/DTBRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java index ecf480de..92611859 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java @@ -7,6 +7,8 @@ import com.tiki.server.documenttimeblockmanager.entity.DTBManager; public interface DTBRepository extends JpaRepository { + List findAllByTimeBlockId(long timeBlockId); + void deleteAllByTimeBlockId(long timeBlockId); void deleteAllByDocumentIdIn(List documentIds); From 9b43c7a4579675e7194d632dbc09fd678338400f Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:27:48 +0900 Subject: [PATCH 26/65] =?UTF-8?q?feat(DTBAdapter):=20=ED=83=80=EC=9E=84=20?= =?UTF-8?q?=EB=B8=94=EB=A1=9D=EA=B3=BC=20=EC=97=B0=EA=B4=80=EB=90=9C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/documenttimeblockmanager/adapter/DTBAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java index 6faaece7..0b8609be 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java @@ -19,6 +19,10 @@ public void saveAll(final TimeBlock timeBlock, final List documentIds) { documentIds.forEach(documentId -> dtbRepository.save(DTBManager.of(timeBlock, documentId))); } + public List getAll(final TimeBlock timeBlock) { + return dtbRepository.findAllByTimeBlockId(timeBlock.getId()); + } + public void deleteAllByTimeBlock(final TimeBlock timeBlock) { dtbRepository.deleteAllByTimeBlockId(timeBlock.getId()); } From db712b57e83e7710a99d45bff6c6f87e3fc5ee50 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:29:09 +0900 Subject: [PATCH 27/65] =?UTF-8?q?delete:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=A0=9C=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 | 4 ---- .../tiki/server/document/repository/DocumentRepository.java | 3 --- .../com/tiki/server/timeblock/service/TimeBlockService.java | 1 - 3 files changed, 8 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 fdcc7546..02a3facf 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -38,10 +38,6 @@ public Document findByIdWithTimeBlock(long documentId) { return document; } - public List findAllByTimeBlockId(long timeBlockId) { - return documentRepository.findAllByTimeBlockId(timeBlockId).stream().map(DocumentVO::from).toList(); - } - public List findAllByTeamIdAndAccessiblePosition(long teamId, Position accessiblePosition) { return documentRepository.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); } 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 63c4dfc2..9de321a8 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -10,9 +10,6 @@ import com.tiki.server.document.entity.Document; public interface DocumentRepository extends JpaRepository { - - List findAllByTimeBlockId(long timeBlockId); - List findAllByFolderId(long folderId); @Query("select d from Document d join fetch d.timeBlock t " diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index a678f9ff..6ba56e3e 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -84,7 +84,6 @@ public TimeBlockDetailGetResponse getTimeBlockDetail( MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); - List documents = documentFinder.findAllByTimeBlockId(timeBlockId); List notes = getNotes(timeBlock.getId()); return TimeBlockDetailGetResponse.from(documents, notes); } From 46f75eed0e3aa40987e03c9facbd075f9447601a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:30:49 +0900 Subject: [PATCH 28/65] =?UTF-8?q?feat(DTBManager):=20getter=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 --- .../tiki/server/documenttimeblockmanager/entity/DTBManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java b/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java index c1ca3e41..6ae496cc 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java @@ -13,9 +13,11 @@ import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Getter; import lombok.NoArgsConstructor; @Entity +@Getter @Builder(access = PRIVATE) @AllArgsConstructor(access = PRIVATE) @NoArgsConstructor(access = PROTECTED) From 5c0563d9feea1e1154c0849e2bb3b23556fa89d9 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:32:13 +0900 Subject: [PATCH 29/65] =?UTF-8?q?refactor:=20=EB=A9=94=EC=86=8C=EB=93=9C?= =?UTF-8?q?=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 orElseThrow 제거 --- .../com/tiki/server/document/adapter/DocumentFinder.java | 5 +++-- src/main/java/com/tiki/server/note/service/NoteService.java | 2 +- 2 files changed, 4 insertions(+), 3 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 02a3facf..7a8b8a3a 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -26,8 +26,9 @@ public List findAllByIdAndTeamId(final List documentIds, final l .toList(); } - public Document findByIdOrElseThrow(final long documentId) { - return documentRepository.findById(documentId).orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); + public Document findById(final long documentId) { + return documentRepository.findById(documentId) + .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); } public Document findByIdWithTimeBlock(long documentId) { diff --git a/src/main/java/com/tiki/server/note/service/NoteService.java b/src/main/java/com/tiki/server/note/service/NoteService.java index df691ab2..0835a74e 100644 --- a/src/main/java/com/tiki/server/note/service/NoteService.java +++ b/src/main/java/com/tiki/server/note/service/NoteService.java @@ -210,7 +210,7 @@ private List getDocumentListMappedByNote(final long noteId) { .map(NoteDocumentManager::getDocumentId) .toList(); return documentIdList.stream() - .map(documentFinder::findByIdOrElseThrow) + .map(documentFinder::findById) .toList(); } From f1f128602592459192ddbf48024d0334463c20cc Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:35:37 +0900 Subject: [PATCH 30/65] =?UTF-8?q?feat(DocumentRepository):=20id=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A1=9C=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 9de321a8..ec436276 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -27,4 +27,6 @@ public interface DocumentRepository extends JpaRepository { List findAllByTeamIdAndFolderIdOrderByCreatedAtDesc(long teamId, Long folderId); Optional findByIdAndTeamId(long id, long teamId); + + List findAllByIdIn(List documentIds); } From 432cf0d14ee3d3145ce6ca388930ddba4a99f9f6 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:35:59 +0900 Subject: [PATCH 31/65] =?UTF-8?q?feat(DocumentFinder):=20id=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=A1=9C=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 | 5 ++++- 1 file changed, 4 insertions(+), 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 7a8b8a3a..b3c8e509 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -10,7 +10,6 @@ import com.tiki.server.document.entity.Document; import com.tiki.server.document.exception.DocumentException; import com.tiki.server.document.repository.DocumentRepository; -import com.tiki.server.document.vo.DocumentVO; import lombok.RequiredArgsConstructor; @@ -59,6 +58,10 @@ public List findAllByFolderId(final long folderId) { return documentRepository.findAllByFolderId(folderId); } + public List findAllByIds(final List documentIds) { + return documentRepository.findAllByIdIn(documentIds); + } + private Document findByIdAndTeamId(long documentId, long teamId) { return documentRepository.findByIdAndTeamId(documentId, teamId) .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); From a9de5ed6bbbd8936c93f32e843051dea9161a9e0 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:36:25 +0900 Subject: [PATCH 32/65] =?UTF-8?q?feat(TimeBlockService):=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=EB=90=9C=20=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 --- .../tiki/server/timeblock/service/TimeBlockService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 6ba56e3e..7574dd46 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -2,7 +2,9 @@ import java.util.List; +import com.tiki.server.document.entity.Document; import com.tiki.server.documenttimeblockmanager.adapter.DTBAdapter; +import com.tiki.server.documenttimeblockmanager.entity.DTBManager; import com.tiki.server.note.adapter.NoteFinder; import com.tiki.server.note.entity.Note; import com.tiki.server.notetimeblockmanager.adapter.NoteTimeBlockManagerFinder; @@ -84,6 +86,7 @@ public TimeBlockDetailGetResponse getTimeBlockDetail( MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); + List documents = getDocuments(timeBlock); List notes = getNotes(timeBlock.getId()); return TimeBlockDetailGetResponse.from(documents, notes); } @@ -109,6 +112,12 @@ private TimeBlock saveTimeBlock( return timeBlockSaver.save(TimeBlock.of(team, accessiblePosition, request)); } + private List getDocuments(final TimeBlock timeBlock) { + List dtbManagers = dtbAdapter.getAll(timeBlock); + List documentIds = dtbManagers.stream().map(DTBManager::getDocumentId).toList(); + return documentFinder.findAllByIds(documentIds); + } + private List getNotes(final long timeBlockId) { List noteTimeBlockManagers = noteTimeBlockManagerFinder.findAllByTimeBlockId(timeBlockId); return noteTimeBlockManagers.stream() From 5219880384ff966e28f9a37f7c9ec30385666d35 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:36:53 +0900 Subject: [PATCH 33/65] =?UTF-8?q?refactor(TimeBlockDetailGetResponse):=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=B0=8F=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=A7=A4=ED=95=91=20=EB=A1=9C=EC=A7=81=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 --- .../response/TimeBlockDetailGetResponse.java | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java b/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java index 4b186524..c01b8f8d 100644 --- a/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java +++ b/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java @@ -4,52 +4,53 @@ import java.util.List; -import com.tiki.server.document.vo.DocumentVO; +import com.tiki.server.document.entity.Document; import com.tiki.server.note.entity.Note; + import lombok.Builder; import lombok.NonNull; @Builder(access = PRIVATE) public record TimeBlockDetailGetResponse( - List documents, - List notes + List documents, + List notes ) { - public static TimeBlockDetailGetResponse from(List documents, List notes) { - return TimeBlockDetailGetResponse.builder() - .documents(documents.stream().map(DocumentGetResponse::from).toList()) - .notes(notes.stream().map(NoteNameGetResponse::from).toList()) - .build(); - } - - @Builder(access = PRIVATE) - public record DocumentGetResponse( - long documentId, - @NonNull String fileName, - @NonNull String fileUrl - ) { - - public static DocumentGetResponse from(DocumentVO document) { - return DocumentGetResponse.builder() - .documentId(document.documentId()) - .fileName(document.fileName()) - .fileUrl(document.fileUrl()) - .build(); - } - } - - @Builder(access = PRIVATE) - public record NoteNameGetResponse( - long noteId, - @NonNull String noteName - ) { - - public static NoteNameGetResponse from(final Note note) { - return NoteNameGetResponse.builder() - .noteId(note.getId()) - .noteName(note.getTitle()) - .build(); - } - } + public static TimeBlockDetailGetResponse from(List documents, List notes) { + return TimeBlockDetailGetResponse.builder() + .documents(documents.stream().map(DocumentGetResponse::from).toList()) + .notes(notes.stream().map(NoteNameGetResponse::from).toList()) + .build(); + } + + @Builder(access = PRIVATE) + public record DocumentGetResponse( + long documentId, + @NonNull String fileName, + @NonNull String fileUrl + ) { + + public static DocumentGetResponse from(Document document) { + return DocumentGetResponse.builder() + .documentId(document.getId()) + .fileName(document.getFileName()) + .fileUrl(document.getFileUrl()) + .build(); + } + } + + @Builder(access = PRIVATE) + public record NoteNameGetResponse( + long noteId, + @NonNull String noteName + ) { + + public static NoteNameGetResponse from(final Note note) { + return NoteNameGetResponse.builder() + .noteId(note.getId()) + .noteName(note.getTitle()) + .build(); + } + } } From 34a688b2de44e9fa4d1d2e86d206b5fe0958afba Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:37:15 +0900 Subject: [PATCH 34/65] =?UTF-8?q?delete:=20DocumentVO=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/vo/DocumentVO.java | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 src/main/java/com/tiki/server/document/vo/DocumentVO.java diff --git a/src/main/java/com/tiki/server/document/vo/DocumentVO.java b/src/main/java/com/tiki/server/document/vo/DocumentVO.java deleted file mode 100644 index 1fa87eb0..00000000 --- a/src/main/java/com/tiki/server/document/vo/DocumentVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.tiki.server.document.vo; - -import static lombok.AccessLevel.PRIVATE; - -import com.tiki.server.document.entity.Document; - -import lombok.Builder; -import lombok.NonNull; - -@Builder(access = PRIVATE) -public record DocumentVO( - long documentId, - @NonNull String fileName, - @NonNull String fileUrl -) { - - public static DocumentVO from(Document document) { - return DocumentVO.builder() - .documentId(document.getId()) - .fileName(document.getFileName()) - .fileUrl(document.getFileUrl()) - .build(); - } -} From 28aa41a413c34db3a6b18de9b2acb2b113c4a8eb Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:40:34 +0900 Subject: [PATCH 35/65] =?UTF-8?q?refactor(TimeBlockDetailGetResponse):=20?= =?UTF-8?q?=EB=82=B4=EB=B6=80=20record=20=EC=A0=91=EA=B7=BC=20=EC=A0=9C?= =?UTF-8?q?=ED=95=9C=EC=9E=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/TimeBlockDetailGetResponse.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java b/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java index c01b8f8d..a1ebb6c4 100644 --- a/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java +++ b/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java @@ -25,13 +25,13 @@ public static TimeBlockDetailGetResponse from(List documents, List Date: Wed, 11 Dec 2024 18:49:19 +0900 Subject: [PATCH 36/65] =?UTF-8?q?feat(DocumentTagInfo):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=9C=EA=B7=B8=20=EC=A0=95=EB=B3=B4=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dto/DocumentTagInfo.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/com/tiki/server/timeblock/service/dto/DocumentTagInfo.java diff --git a/src/main/java/com/tiki/server/timeblock/service/dto/DocumentTagInfo.java b/src/main/java/com/tiki/server/timeblock/service/dto/DocumentTagInfo.java new file mode 100644 index 00000000..553c3ede --- /dev/null +++ b/src/main/java/com/tiki/server/timeblock/service/dto/DocumentTagInfo.java @@ -0,0 +1,27 @@ +package com.tiki.server.timeblock.service.dto; + +import static lombok.AccessLevel.PRIVATE; + +import com.tiki.server.document.entity.Document; +import com.tiki.server.documenttimeblockmanager.entity.DTBManager; + +import lombok.Builder; +import lombok.NonNull; + +@Builder(access = PRIVATE) +public record DocumentTagInfo( + long documentId, + @NonNull String fileName, + @NonNull String fileUrl, + long tagId +) { + + public static DocumentTagInfo of(final Document document, final DTBManager dtbManager) { + return DocumentTagInfo.builder() + .documentId(document.getId()) + .fileName(document.getFileName()) + .fileUrl(document.getFileUrl()) + .tagId(dtbManager.getId()) + .build(); + } +} From aaff8f90de80c17a525f3f4a31c5c0abe6bf4177 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:49:41 +0900 Subject: [PATCH 37/65] =?UTF-8?q?feat(TimeBlockService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=9C=EA=B7=B8=20=EC=A0=95=EB=B3=B4=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 --- .../timeblock/service/TimeBlockService.java | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 7574dd46..c6af02fc 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -1,6 +1,8 @@ package com.tiki.server.timeblock.service; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import com.tiki.server.document.entity.Document; import com.tiki.server.documenttimeblockmanager.adapter.DTBAdapter; @@ -28,6 +30,7 @@ import com.tiki.server.timeblock.dto.response.TimeBlockDetailGetResponse; import com.tiki.server.timeblock.dto.response.TimelineGetResponse; import com.tiki.server.timeblock.entity.TimeBlock; +import com.tiki.server.timeblock.service.dto.DocumentTagInfo; import lombok.RequiredArgsConstructor; @@ -42,7 +45,7 @@ public class TimeBlockService { private final TimeBlockFinder timeBlockFinder; private final TimeBlockDeleter timeBlockDeleter; private final DocumentFinder documentFinder; - private final DTBAdapter dtbAdapter; + private final DTBAdapter dtbAdapter; private final NoteTimeBlockManagerFinder noteTimeBlockManagerFinder; private final NoteFinder noteFinder; @@ -57,18 +60,18 @@ public TimeBlockCreateResponse createTimeBlock( MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); Position accessiblePosition = Position.getAccessiblePosition(type); memberTeamManager.checkMemberAccessible(accessiblePosition); - validateDocuments(team, request.documentIds()); + validateDocuments(team, request.documentIds()); TimeBlock timeBlock = saveTimeBlock(team, accessiblePosition, request); dtbAdapter.saveAll(timeBlock, request.documentIds()); return TimeBlockCreateResponse.of(timeBlock.getId()); } public TimelineGetResponse getTimeline( - final long memberId, - final long teamId, - final String type, - final String date - ) { + final long memberId, + final long teamId, + final String type, + final String date + ) { Team team = teamFinder.findById(teamId); MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); Position accessiblePosition = Position.getAccessiblePosition(type); @@ -79,14 +82,14 @@ public TimelineGetResponse getTimeline( } public TimeBlockDetailGetResponse getTimeBlockDetail( - final long memberId, - final long teamId, - final long timeBlockId - ) { + final long memberId, + final long teamId, + final long timeBlockId + ) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); - List documents = getDocuments(timeBlock); + List documents = getDocumentsInfo(timeBlock); List notes = getNotes(timeBlock.getId()); return TimeBlockDetailGetResponse.from(documents, notes); } @@ -100,22 +103,28 @@ public void deleteTimeBlock(final long memberId, final long teamId, final long t timeBlockDeleter.deleteById(timeBlock.getId()); } - private void validateDocuments(final Team team, final List documentIds) { - documentFinder.findAllByIdAndTeamId(documentIds, team.getId()); - } + private void validateDocuments(final Team team, final List documentIds) { + documentFinder.findAllByIdAndTeamId(documentIds, team.getId()); + } private TimeBlock saveTimeBlock( - final Team team, - final Position accessiblePosition, - final TimeBlockCreateRequest request - ) { + final Team team, + final Position accessiblePosition, + final TimeBlockCreateRequest request + ) { return timeBlockSaver.save(TimeBlock.of(team, accessiblePosition, request)); } - private List getDocuments(final TimeBlock timeBlock) { + private List getDocumentsInfo(final TimeBlock timeBlock) { List dtbManagers = dtbAdapter.getAll(timeBlock); - List documentIds = dtbManagers.stream().map(DTBManager::getDocumentId).toList(); - return documentFinder.findAllByIds(documentIds); + return dtbManagers.stream() + .map(this::getDocumentTagInfo) + .toList(); + } + + private DocumentTagInfo getDocumentTagInfo(final DTBManager dtbManager) { + Document document = documentFinder.findById(dtbManager.getDocumentId()); + return DocumentTagInfo.of(document, dtbManager); } private List getNotes(final long timeBlockId) { From 70f68bd3790576d89178ee6e0616c85fc6dc7f61 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 18:50:10 +0900 Subject: [PATCH 38/65] =?UTF-8?q?refactor(TimeBlockDetailGetResponse):=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=B0=8F=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=A7=A4=ED=95=91=20=EB=A1=9C=EC=A7=81=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 --- .../response/TimeBlockDetailGetResponse.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java b/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java index a1ebb6c4..acd356dd 100644 --- a/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java +++ b/src/main/java/com/tiki/server/timeblock/dto/response/TimeBlockDetailGetResponse.java @@ -4,9 +4,8 @@ import java.util.List; -import com.tiki.server.document.entity.Document; - import com.tiki.server.note.entity.Note; +import com.tiki.server.timeblock.service.dto.DocumentTagInfo; import lombok.Builder; import lombok.NonNull; @@ -17,7 +16,7 @@ public record TimeBlockDetailGetResponse( List notes ) { - public static TimeBlockDetailGetResponse from(List documents, List notes) { + public static TimeBlockDetailGetResponse from(List documents, List notes) { return TimeBlockDetailGetResponse.builder() .documents(documents.stream().map(DocumentGetResponse::from).toList()) .notes(notes.stream().map(NoteNameGetResponse::from).toList()) @@ -28,14 +27,16 @@ public static TimeBlockDetailGetResponse from(List documents, List Date: Wed, 11 Dec 2024 18:50:29 +0900 Subject: [PATCH 39/65] =?UTF-8?q?chore(TimeBlockService):=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 --- .../com/tiki/server/timeblock/service/TimeBlockService.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index c6af02fc..2e9f8230 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -1,8 +1,6 @@ package com.tiki.server.timeblock.service; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import com.tiki.server.document.entity.Document; import com.tiki.server.documenttimeblockmanager.adapter.DTBAdapter; @@ -17,7 +15,6 @@ import com.tiki.server.common.entity.Position; import com.tiki.server.document.adapter.DocumentFinder; -import com.tiki.server.document.vo.DocumentVO; import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; import com.tiki.server.memberteammanager.entity.MemberTeamManager; import com.tiki.server.team.adapter.TeamFinder; From 9f4435b990952e282a8b943a8f5b8a0e5882a705 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:02:52 +0900 Subject: [PATCH 40/65] =?UTF-8?q?feat(TimeBlockRepository):=20id=EC=99=80?= =?UTF-8?q?=20=ED=8C=80=20id=EB=A1=9C=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/timeblock/repository/TimeBlockRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/repository/TimeBlockRepository.java b/src/main/java/com/tiki/server/timeblock/repository/TimeBlockRepository.java index c3d0e6f4..6b2ff15a 100644 --- a/src/main/java/com/tiki/server/timeblock/repository/TimeBlockRepository.java +++ b/src/main/java/com/tiki/server/timeblock/repository/TimeBlockRepository.java @@ -1,6 +1,7 @@ package com.tiki.server.timeblock.repository; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -9,6 +10,7 @@ import com.tiki.server.timeblock.entity.TimeBlock; public interface TimeBlockRepository extends JpaRepository { + Optional findByIdAndTeamId(long id, long teamId); void deleteAllByTeamId(long teamId); From d249eacff250eb3c143e122d9c378c804c8ba2c9 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:03:19 +0900 Subject: [PATCH 41/65] =?UTF-8?q?feat(TimeBlockFinder):=20id=EC=99=80=20?= =?UTF-8?q?=ED=8C=80=20id=EB=A1=9C=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/timeblock/adapter/TimeBlockFinder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java b/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java index af1fce66..9777a9a0 100644 --- a/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java +++ b/src/main/java/com/tiki/server/timeblock/adapter/TimeBlockFinder.java @@ -22,6 +22,11 @@ public TimeBlock findById(final long id) { .orElseThrow(() -> new TimeBlockException(INVALID_TIME_BLOCK)); } + public TimeBlock findByIdAndTeamId(final long id, final long teamId) { + return timeBlockRepository.findByIdAndTeamId(id, teamId) + .orElseThrow(() -> new TimeBlockException(INVALID_TIME_BLOCK)); + } + public List findByTeamAndAccessiblePositionAndDate( final long teamId, final String accessiblePosition, From 7ff2ae99383edffe053dcb00734f9ab17114eed6 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:04:06 +0900 Subject: [PATCH 42/65] =?UTF-8?q?feat(SuccessMessage):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=9C=EA=B7=B8=20=EC=84=B1=EA=B3=B5=20=EB=A9=94?= =?UTF-8?q?=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/timeblock/message/SuccessMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/timeblock/message/SuccessMessage.java b/src/main/java/com/tiki/server/timeblock/message/SuccessMessage.java index f1ce45ef..3e3dd441 100644 --- a/src/main/java/com/tiki/server/timeblock/message/SuccessMessage.java +++ b/src/main/java/com/tiki/server/timeblock/message/SuccessMessage.java @@ -9,7 +9,8 @@ public enum SuccessMessage { SUCCESS_CREATE_TIME_BLOCK("타임 블록 생성 성공"), SUCCESS_GET_TIMELINE("타임라인 조회 성공"), - SUCCESS_GET_TIME_BLOCK_DETAIL("타임 블록 상세 정보 조회 성공"); + SUCCESS_GET_TIME_BLOCK_DETAIL("타임 블록 상세 정보 조회 성공"), + SUCCESS_CREATE_DOCUMENT_TAG("파일 태그 성공"); private final String message; } From c10a2ddc86a3bc8eaaa25760278281503416fbe4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:04:24 +0900 Subject: [PATCH 43/65] =?UTF-8?q?feat(TimeBlockService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=9C=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timeblock/service/TimeBlockService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 2e9f8230..20608383 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -100,6 +100,21 @@ public void deleteTimeBlock(final long memberId, final long teamId, final long t timeBlockDeleter.deleteById(timeBlock.getId()); } + @Transactional + public void createDocumentTag( + final long memberId, + final long teamId, + final long timeBlockId, + final List documentIds + ) { + Team team = teamFinder.findById(teamId); + MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + TimeBlock timeBlock = timeBlockFinder.findByIdAndTeamId(timeBlockId, teamId); + memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); + validateDocuments(team, documentIds); + dtbAdapter.saveAll(timeBlock, documentIds); + } + private void validateDocuments(final Team team, final List documentIds) { documentFinder.findAllByIdAndTeamId(documentIds, team.getId()); } From af6f8206bfaf4855c7fc3820f48b596d5a0c4dde Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:04:40 +0900 Subject: [PATCH 44/65] =?UTF-8?q?feat(TimeBlockController):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=9C=EA=B7=B8=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TimeBlockController.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java index 753b0bc3..1a0b59f4 100644 --- a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java +++ b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java @@ -1,12 +1,15 @@ package com.tiki.server.timeblock.controller; import static com.tiki.server.common.dto.SuccessResponse.*; +import static com.tiki.server.timeblock.message.SuccessMessage.SUCCESS_CREATE_DOCUMENT_TAG; import static com.tiki.server.timeblock.message.SuccessMessage.SUCCESS_CREATE_TIME_BLOCK; import static com.tiki.server.timeblock.message.SuccessMessage.SUCCESS_GET_TIMELINE; import static com.tiki.server.timeblock.message.SuccessMessage.SUCCESS_GET_TIME_BLOCK_DETAIL; import java.security.Principal; +import java.util.List; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -15,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import com.tiki.server.common.dto.SuccessResponse; @@ -86,4 +90,17 @@ public ResponseEntity deleteTimeBlock( timeBlockService.deleteTimeBlock(memberId, teamId, timeBlockId); return ResponseEntity.noContent().build(); } + + @ResponseStatus(HttpStatus.CREATED) + @PostMapping("/teams/{teamId}/time-block/{timeBlockId}") + public SuccessResponse createDocumentTag( + final Principal principal, + @PathVariable final long teamId, + @PathVariable final long timeBlockId, + @RequestParam("documentId") final List documentIds + ) { + long memberId = Long.parseLong(principal.getName()); + timeBlockService.createDocumentTag(memberId, teamId, timeBlockId, documentIds); + return SuccessResponse.success(SUCCESS_CREATE_DOCUMENT_TAG.getMessage()); + } } From 3acf9affae7fdca17b9a78257a7d37c863d1c205 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:05:27 +0900 Subject: [PATCH 45/65] =?UTF-8?q?fix(TimeBlockService):=20=ED=8C=80?= =?UTF-8?q?=EC=97=90=20=EC=86=8D=ED=95=9C=20=ED=83=80=EC=9E=84=20=EB=B8=94?= =?UTF-8?q?=EB=A1=9D=EB=A7=8C=20=EC=A1=B0=ED=9A=8C=ED=95=A0=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=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 --- .../com/tiki/server/timeblock/service/TimeBlockService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 20608383..130e45ea 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -84,7 +84,7 @@ public TimeBlockDetailGetResponse getTimeBlockDetail( final long timeBlockId ) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); + TimeBlock timeBlock = timeBlockFinder.findByIdAndTeamId(timeBlockId, teamId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); List documents = getDocumentsInfo(timeBlock); List notes = getNotes(timeBlock.getId()); @@ -94,7 +94,7 @@ public TimeBlockDetailGetResponse getTimeBlockDetail( @Transactional public void deleteTimeBlock(final long memberId, final long teamId, final long timeBlockId) { MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - TimeBlock timeBlock = timeBlockFinder.findById(timeBlockId); + TimeBlock timeBlock = timeBlockFinder.findByIdAndTeamId(timeBlockId, teamId); memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); dtbAdapter.deleteAllByTimeBlock(timeBlock); timeBlockDeleter.deleteById(timeBlock.getId()); From 6b4565821fe7f068060382ad1ab50f72e29f953e Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:15:33 +0900 Subject: [PATCH 46/65] =?UTF-8?q?refactor:=20=EB=A9=94=EC=86=8C=EB=93=9C?= =?UTF-8?q?=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 --- .../server/documenttimeblockmanager/adapter/DTBAdapter.java | 2 +- .../com/tiki/server/timeblock/service/TimeBlockService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java index 0b8609be..9a93667e 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java @@ -19,7 +19,7 @@ public void saveAll(final TimeBlock timeBlock, final List documentIds) { documentIds.forEach(documentId -> dtbRepository.save(DTBManager.of(timeBlock, documentId))); } - public List getAll(final TimeBlock timeBlock) { + public List getAllByTimeBlock(final TimeBlock timeBlock) { return dtbRepository.findAllByTimeBlockId(timeBlock.getId()); } diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 130e45ea..174022d2 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -128,7 +128,7 @@ private TimeBlock saveTimeBlock( } private List getDocumentsInfo(final TimeBlock timeBlock) { - List dtbManagers = dtbAdapter.getAll(timeBlock); + List dtbManagers = dtbAdapter.getAllByTimeBlock(timeBlock); return dtbManagers.stream() .map(this::getDocumentTagInfo) .toList(); From 58b77b355f3504a3f243935c545099e333688e40 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:24:16 +0900 Subject: [PATCH 47/65] =?UTF-8?q?feat(DTBAdapter):=20id=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/documenttimeblockmanager/adapter/DTBAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java index 9a93667e..c4e9b955 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java @@ -23,6 +23,10 @@ public List getAllByTimeBlock(final TimeBlock timeBlock) { return dtbRepository.findAllByTimeBlockId(timeBlock.getId()); } + public List getAllByIds(final List ids) { + return dtbRepository.findAllByIdIn(ids); + } + public void deleteAllByTimeBlock(final TimeBlock timeBlock) { dtbRepository.deleteAllByTimeBlockId(timeBlock.getId()); } From 14255579f27a9c7e7ba6e4b1285ee3789a70f9cb Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:24:32 +0900 Subject: [PATCH 48/65] =?UTF-8?q?feat(DTBAdapter):=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=A1=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/documenttimeblockmanager/adapter/DTBAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java index c4e9b955..0866f7f7 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/adapter/DTBAdapter.java @@ -27,6 +27,10 @@ public List getAllByIds(final List ids) { return dtbRepository.findAllByIdIn(ids); } + public void deleteAll(final List dtbManagers) { + dtbRepository.deleteAll(dtbManagers); + } + public void deleteAllByTimeBlock(final TimeBlock timeBlock) { dtbRepository.deleteAllByTimeBlockId(timeBlock.getId()); } From 3104c4695763978085058a54a946685005c76a01 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:24:50 +0900 Subject: [PATCH 49/65] =?UTF-8?q?feat(DTBManager):=20=ED=83=80=EC=9E=84=20?= =?UTF-8?q?=EB=B8=94=EB=A1=9D=EC=9D=84=20=ED=86=B5=ED=95=B4=20=EC=9C=A0?= =?UTF-8?q?=ED=9A=A8=EC=84=B1=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../documenttimeblockmanager/entity/DTBManager.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java b/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java index 6ae496cc..d7195198 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/entity/DTBManager.java @@ -1,11 +1,13 @@ package com.tiki.server.documenttimeblockmanager.entity; +import static com.tiki.server.timeblock.message.ErrorCode.INVALID_DOCUMENT_TAG; import static jakarta.persistence.GenerationType.IDENTITY; import static lombok.AccessLevel.PRIVATE; import static lombok.AccessLevel.PROTECTED; import com.tiki.server.common.entity.BaseTime; import com.tiki.server.timeblock.entity.TimeBlock; +import com.tiki.server.timeblock.exception.TimeBlockException; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -38,4 +40,10 @@ public static DTBManager of(final TimeBlock timeBlock, final long documentId) { .timeBlockId(timeBlock.getId()) .build(); } + + public void validateTimeBlock(final TimeBlock timeBlock) { + if (this.timeBlockId != timeBlock.getId()) { + throw new TimeBlockException(INVALID_DOCUMENT_TAG); + } + } } From aa2bfbff6bce75b632bc7faeaf0a8991be8eec02 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:25:02 +0900 Subject: [PATCH 50/65] =?UTF-8?q?feat(DTBRepository):=20id=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../documenttimeblockmanager/repository/DTBRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java index 92611859..3dec3420 100644 --- a/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java +++ b/src/main/java/com/tiki/server/documenttimeblockmanager/repository/DTBRepository.java @@ -9,6 +9,8 @@ public interface DTBRepository extends JpaRepository { List findAllByTimeBlockId(long timeBlockId); + List findAllByIdIn(List ids); + void deleteAllByTimeBlockId(long timeBlockId); void deleteAllByDocumentIdIn(List documentIds); From 2db1ea332b3d95cfa6a850d9893392b52f9fb270 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:25:38 +0900 Subject: [PATCH 51/65] =?UTF-8?q?feat(ErrorCode):=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=83=9C=EA=B7=B8=20=EB=A9=94=EC=84=B8=EC=A7=80=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/timeblock/message/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/tiki/server/timeblock/message/ErrorCode.java b/src/main/java/com/tiki/server/timeblock/message/ErrorCode.java index 98509f12..cafa8d6d 100644 --- a/src/main/java/com/tiki/server/timeblock/message/ErrorCode.java +++ b/src/main/java/com/tiki/server/timeblock/message/ErrorCode.java @@ -15,6 +15,7 @@ public enum ErrorCode { /* 400 BAD_REQUEST : 잘못된 요청 */ INVALID_TYPE(BAD_REQUEST, "유효한 타입이 아닙니다."), + INVALID_DOCUMENT_TAG(BAD_REQUEST, "유효한 파일이 아닙니다"), /* 404 NOT_FOUND : 자원을 찾을 수 없음 */ INVALID_TIME_BLOCK(NOT_FOUND, "유효하지 않은 타임 블록입니다."); From 38aeb33cf95c6f9e9181c1a12a1d1467fe864ee6 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:25:51 +0900 Subject: [PATCH 52/65] =?UTF-8?q?feat(TimeBlockService):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=9C=EA=B7=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timeblock/service/TimeBlockService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java index 174022d2..26a66ba8 100644 --- a/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java +++ b/src/main/java/com/tiki/server/timeblock/service/TimeBlockService.java @@ -115,6 +115,21 @@ public void createDocumentTag( dtbAdapter.saveAll(timeBlock, documentIds); } + @Transactional + public void deleteDocumentTag( + final long memberId, + final long teamId, + final long timeBlockId, + final List tagIds + ) { + MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); + TimeBlock timeBlock = timeBlockFinder.findByIdAndTeamId(timeBlockId, teamId); + memberTeamManager.checkMemberAccessible(timeBlock.getAccessiblePosition()); + List dtbManagers = dtbAdapter.getAllByIds(tagIds); + dtbManagers.forEach(dtbManager -> dtbManager.validateTimeBlock(timeBlock)); + dtbAdapter.deleteAll(dtbManagers); + } + private void validateDocuments(final Team team, final List documentIds) { documentFinder.findAllByIdAndTeamId(documentIds, team.getId()); } From cb792f9c06bd88831ec373db44f877e099ef37f4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:26:09 +0900 Subject: [PATCH 53/65] =?UTF-8?q?feat(TimeBlockController):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=9C=EA=B7=B8=20=EC=82=AD=EC=A0=9C=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timeblock/controller/TimeBlockController.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java index 1a0b59f4..fd79e47d 100644 --- a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java +++ b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java @@ -103,4 +103,17 @@ public SuccessResponse createDocumentTag( timeBlockService.createDocumentTag(memberId, teamId, timeBlockId, documentIds); return SuccessResponse.success(SUCCESS_CREATE_DOCUMENT_TAG.getMessage()); } + + @ResponseStatus(HttpStatus.NO_CONTENT) + @DeleteMapping("/teams/{teamId}/time-block/{timeBlockId}") + public SuccessResponse deleteDocumentTag( + final Principal principal, + @PathVariable final long teamId, + @PathVariable final long timeBlockId, + @RequestParam("tagId") final List tagIds + ) { + long memberId = Long.parseLong(principal.getName()); + timeBlockService.deleteDocumentTag(memberId, teamId, timeBlockId, tagIds); + return SuccessResponse.success(SUCCESS_CREATE_DOCUMENT_TAG.getMessage()); + } } From a2c65dc5d8a7c1e08e09444ca37c54d90691e21a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:31:08 +0900 Subject: [PATCH 54/65] =?UTF-8?q?delete:=20=EA=B8=B0=EC=A1=B4=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=82=AD=EC=A0=9C=20api=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/adapter/DocumentDeleter.java | 9 ----- .../document/adapter/DocumentFinder.java | 13 ------- .../controller/DocumentController.java | 12 ------ .../docs/DocumentControllerDocs.java | 38 ------------------- .../repository/DocumentRepository.java | 7 ---- .../document/service/DocumentService.java | 8 ---- 6 files changed, 87 deletions(-) diff --git a/src/main/java/com/tiki/server/document/adapter/DocumentDeleter.java b/src/main/java/com/tiki/server/document/adapter/DocumentDeleter.java index 2c343a3c..1a4c113c 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentDeleter.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentDeleter.java @@ -5,7 +5,6 @@ import com.tiki.server.common.support.RepositoryAdapter; import com.tiki.server.document.entity.Document; import com.tiki.server.document.repository.DocumentRepository; -import com.tiki.server.document.vo.DocumentVO; import lombok.RequiredArgsConstructor; @@ -15,15 +14,7 @@ public class DocumentDeleter { private final DocumentRepository documentRepository; - public void delete(Document document) { - documentRepository.delete(document); - } - public void deleteAll(List documents) { documentRepository.deleteAll(documents); } - - public void deleteAllByTimeBlockId(long timeBlockId) { - documentRepository.deleteAllByTimeBlockId(timeBlockId); - } } 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 b3c8e509..b633f518 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -3,7 +3,6 @@ import static com.tiki.server.document.message.ErrorCode.INVALID_DOCUMENT; import java.util.List; -import java.util.Objects; import com.tiki.server.common.entity.Position; import com.tiki.server.common.support.RepositoryAdapter; @@ -30,14 +29,6 @@ public Document findById(final long documentId) { .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); } - public Document findByIdWithTimeBlock(long documentId) { - Document document = documentRepository.findByIdWithTimeBlock(documentId); - if (Objects.isNull(document)) { - throw new DocumentException(INVALID_DOCUMENT); - } - return document; - } - public List findAllByTeamIdAndAccessiblePosition(long teamId, Position accessiblePosition) { return documentRepository.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); } @@ -58,10 +49,6 @@ public List findAllByFolderId(final long folderId) { return documentRepository.findAllByFolderId(folderId); } - public List findAllByIds(final List documentIds) { - return documentRepository.findAllByIdIn(documentIds); - } - private Document findByIdAndTeamId(long documentId, long teamId) { return documentRepository.findByIdAndTeamId(documentId, teamId) .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); 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 671c2ed4..6fbf95d7 100644 --- a/src/main/java/com/tiki/server/document/controller/DocumentController.java +++ b/src/main/java/com/tiki/server/document/controller/DocumentController.java @@ -46,18 +46,6 @@ public ResponseEntity> getAllDocuments( return ResponseEntity.ok(SuccessResponse.success(SUCCESS_GET_DOCUMENTS.getMessage(), response)); } - @Override - @DeleteMapping("/documents/team/{teamId}/document/{documentId}") - public ResponseEntity deleteDocument( - final Principal principal, - @PathVariable final long teamId, - @PathVariable final long documentId - ) { - long memberId = Long.parseLong(principal.getName()); - documentService.deleteDocument(memberId, teamId, documentId); - return ResponseEntity.noContent().build(); - } - @PostMapping("/teams/{teamId}/documents") public ResponseEntity> createDocuments( final Principal principal, diff --git a/src/main/java/com/tiki/server/document/controller/docs/DocumentControllerDocs.java b/src/main/java/com/tiki/server/document/controller/docs/DocumentControllerDocs.java index dd8f2e17..7ef0937a 100644 --- a/src/main/java/com/tiki/server/document/controller/docs/DocumentControllerDocs.java +++ b/src/main/java/com/tiki/server/document/controller/docs/DocumentControllerDocs.java @@ -64,44 +64,6 @@ ResponseEntity> getAllDocuments( ) @RequestParam String type ); - @Operation( - summary = "문서 삭제", - description = "문서를 삭제한다.", - responses = { - @ApiResponse(responseCode = "204", description = "성공"), - @ApiResponse( - responseCode = "403", - description = "접근 권한 없음", - content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - @ApiResponse( - responseCode = "404", - description = "팀에 존재하지 않는 회원, 유효하지 않은 문서", - content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - @ApiResponse( - responseCode = "4xx", - description = "클라이언트(요청) 오류", - content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - @ApiResponse( - responseCode = "500", - description = "서버 내부 오류", - content = @Content(schema = @Schema(implementation = ErrorResponse.class)))} - ) - ResponseEntity deleteDocument( - @Parameter(hidden = true) Principal principal, - @Parameter( - name = "teamId", - description = "팀 id", - in = ParameterIn.PATH, - example = "1" - ) @PathVariable long teamId, - @Parameter( - name = "documentId", - description = "문서 id", - in = ParameterIn.PATH, - example = "1" - ) @PathVariable long documentId - ); - @Operation( summary = "문서 생성", description = "문서를 여러 개 생성한다.", 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 ec436276..8d9ffe5d 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -19,14 +19,7 @@ public interface DocumentRepository extends JpaRepository { @Query("select d from Document d join d.timeBlock t where t.team.id = :teamId") List findAllByTeamId(long teamId); - @Query("select d from Document d join fetch d.timeBlock where d.id = :documentId") - Document findByIdWithTimeBlock(long documentId); - - void deleteAllByTimeBlockId(long timeBlockId); - List findAllByTeamIdAndFolderIdOrderByCreatedAtDesc(long teamId, Long folderId); Optional findByIdAndTeamId(long id, long teamId); - - List findAllByIdIn(List documentIds); } 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 457002a8..178c4909 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -52,14 +52,6 @@ public DocumentsGetResponse getAllDocuments(final long memberId, final long team return getAllDocumentsByType(teamId, accessiblePosition); } - @Transactional - public void deleteDocument(final long memberId, final long teamId, final long documentId) { - MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); - Document document = documentFinder.findByIdWithTimeBlock(documentId); - // memberTeamManager.checkMemberAccessible(document.getTimeBlock().getAccessiblePosition()); - documentDeleter.delete(document); - } - @Transactional public void createDocuments(final long memberId, final long teamId, final Long folderId, final DocumentsCreateRequest request) { From 75a77aec0ca4dbab4f715226783c030e6af5ef81 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:32:07 +0900 Subject: [PATCH 55/65] =?UTF-8?q?chore(DocumentRepository):=20=ED=8C=80=20?= =?UTF-8?q?id=EB=A1=9C=20=ED=8C=8C=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=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/document/repository/DocumentRepository.java | 1 - 1 file changed, 1 deletion(-) 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 8d9ffe5d..4f04e456 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -16,7 +16,6 @@ public interface DocumentRepository extends JpaRepository { + "where t.team.id = :teamId and t.accessiblePosition = :position order by d.createdAt asc") List findAllByTeamIdAndAccessiblePosition(long teamId, Position position); - @Query("select d from Document d join d.timeBlock t where t.team.id = :teamId") List findAllByTeamId(long teamId); List findAllByTeamIdAndFolderIdOrderByCreatedAtDesc(long teamId, Long folderId); From c08bedb4305aa9d7d7527466a053cb6b840070d4 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:34:36 +0900 Subject: [PATCH 56/65] =?UTF-8?q?refactor(DocumentService):=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=ED=8C=8C=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=84=EC=8B=9C=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 | 3 ++- 1 file changed, 2 insertions(+), 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 178c4909..3fc49873 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -49,7 +49,8 @@ public DocumentsGetResponse getAllDocuments(final long memberId, final long team MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); Position accessiblePosition = Position.getAccessiblePosition(type); memberTeamManager.checkMemberAccessible(accessiblePosition); - return getAllDocumentsByType(teamId, accessiblePosition); + List documents = documentFinder.findAllByTeamId(teamId); + return DocumentsGetResponse.from(documents); } @Transactional From fd58e4a7aacb7f226d47951a5badee4e04ffb62b Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:36:53 +0900 Subject: [PATCH 57/65] =?UTF-8?q?feat:=20key=20=EC=BB=AC=EB=9F=BC=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/document/adapter/DocumentSaver.java | 1 + .../server/document/dto/request/DocumentCreateRequest.java | 2 ++ .../com/tiki/server/document/entity/DeletedDocument.java | 2 ++ src/main/java/com/tiki/server/document/entity/Document.java | 6 +++++- 4 files changed, 10 insertions(+), 1 deletion(-) 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 8648cb85..029df04a 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java @@ -28,6 +28,7 @@ private Document create(final DeletedDocument deletedDocument) { deletedDocument.getFileName(), deletedDocument.getFileUrl(), deletedDocument.getCapacity(), + deletedDocument.getFileKey(), deletedDocument.getTeamId() ); } diff --git a/src/main/java/com/tiki/server/document/dto/request/DocumentCreateRequest.java b/src/main/java/com/tiki/server/document/dto/request/DocumentCreateRequest.java index f53dff20..9c4da95f 100644 --- a/src/main/java/com/tiki/server/document/dto/request/DocumentCreateRequest.java +++ b/src/main/java/com/tiki/server/document/dto/request/DocumentCreateRequest.java @@ -8,6 +8,8 @@ public record DocumentCreateRequest( @NonNull String fileName, @Schema(description = "파일 url", example = "https://.../tiki.jpg") @NonNull String fileUrl, + @Schema(description = "파일 key", example = "....jpg") + @NonNull String fileKey, @Schema(description = "파일 용량", example = "1.23") double capacity ) { 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 5f1b352f..0007a031 100644 --- a/src/main/java/com/tiki/server/document/entity/DeletedDocument.java +++ b/src/main/java/com/tiki/server/document/entity/DeletedDocument.java @@ -31,6 +31,8 @@ public class DeletedDocument extends BaseTime { private String fileUrl; + private String fileKey; + private long teamId; private double capacity; 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 e6bd5e5a..34b5e8cb 100644 --- a/src/main/java/com/tiki/server/document/entity/Document.java +++ b/src/main/java/com/tiki/server/document/entity/Document.java @@ -36,6 +36,8 @@ public class Document extends BaseTime { private String fileUrl; + private String fileKey; + private double capacity; private long teamId; @@ -47,17 +49,19 @@ public static Document of(final DocumentCreateRequest request, final long teamId .fileName(request.fileName()) .fileUrl(request.fileUrl()) .capacity(request.capacity()) + .fileKey(request.fileKey()) .teamId(teamId) .folderId(folderId) .build(); } public static Document restore(final String fileName, final String fileUrl, - final double capacity, final long teamId) { + final double capacity, final String fileKey, final long teamId) { return Document.builder() .fileName(fileName) .fileUrl(fileUrl) .capacity(capacity) + .fileKey(fileKey) .teamId(teamId) .folderId(null) .build(); From bfccd86219897a95a841d1ce08503a5ea21e29df Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:38:03 +0900 Subject: [PATCH 58/65] =?UTF-8?q?refactor:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=B3=B5=EA=B5=AC=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=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/adapter/DocumentSaver.java | 8 +------- .../com/tiki/server/document/entity/Document.java | 13 ++++++------- 2 files changed, 7 insertions(+), 14 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 029df04a..d86f99b7 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentSaver.java @@ -24,12 +24,6 @@ public void restore(final List deletedDocuments) { } private Document create(final DeletedDocument deletedDocument) { - return Document.restore( - deletedDocument.getFileName(), - deletedDocument.getFileUrl(), - deletedDocument.getCapacity(), - deletedDocument.getFileKey(), - deletedDocument.getTeamId() - ); + return Document.restore(deletedDocument); } } 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 34b5e8cb..7fc463af 100644 --- a/src/main/java/com/tiki/server/document/entity/Document.java +++ b/src/main/java/com/tiki/server/document/entity/Document.java @@ -55,14 +55,13 @@ public static Document of(final DocumentCreateRequest request, final long teamId .build(); } - public static Document restore(final String fileName, final String fileUrl, - final double capacity, final String fileKey, final long teamId) { + public static Document restore(final DeletedDocument deletedDocument) { return Document.builder() - .fileName(fileName) - .fileUrl(fileUrl) - .capacity(capacity) - .fileKey(fileKey) - .teamId(teamId) + .fileName(deletedDocument.getFileName()) + .fileUrl(deletedDocument.getFileUrl()) + .capacity(deletedDocument.getCapacity()) + .fileKey(deletedDocument.getFileKey()) + .teamId(deletedDocument.getTeamId()) .folderId(null) .build(); } From 3d0829a82a13c9415e00654fe0b479f772197892 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:38:54 +0900 Subject: [PATCH 59/65] =?UTF-8?q?refactor:=20=EA=B8=B0=EC=A1=B4=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=9E=84=EC=8B=9C=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/document/adapter/DocumentFinder.java | 7 +++---- .../server/document/repository/DocumentRepository.java | 6 +++--- .../com/tiki/server/document/service/DocumentService.java | 8 ++++---- 3 files changed, 10 insertions(+), 11 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 b633f518..acf7a7dc 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -4,7 +4,6 @@ import java.util.List; -import com.tiki.server.common.entity.Position; import com.tiki.server.common.support.RepositoryAdapter; import com.tiki.server.document.entity.Document; import com.tiki.server.document.exception.DocumentException; @@ -29,9 +28,9 @@ public Document findById(final long documentId) { .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); } - public List findAllByTeamIdAndAccessiblePosition(long teamId, Position accessiblePosition) { - return documentRepository.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); - } + // public List findAllByTeamIdAndAccessiblePosition(long teamId, Position accessiblePosition) { + // return documentRepository.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); + // } public List findAllByTeamId(long teamId) { return documentRepository.findAllByTeamId(teamId); 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 4f04e456..97cb8a88 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -12,9 +12,9 @@ public interface DocumentRepository extends JpaRepository { 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); + // @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); List findAllByTeamId(long teamId); 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 3fc49873..f6c8ee1b 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -100,10 +100,10 @@ public DeletedDocumentsGetResponse getTrash(final long memberId, final long team return DeletedDocumentsGetResponse.from(deletedDocuments); } - private DocumentsGetResponse getAllDocumentsByType(final long teamId, final Position accessiblePosition) { - List documents = documentFinder.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); - return DocumentsGetResponse.from(documents); - } + // private DocumentsGetResponse getAllDocumentsByType(final long teamId, final Position accessiblePosition) { + // List documents = documentFinder.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); + // return DocumentsGetResponse.from(documents); + // } private void validateFolder(final Long folderId, final long teamId) { if (folderId == null) { From 9fb0a62389b84fc4fd15a4cf3d836f4c044af2d7 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:41:56 +0900 Subject: [PATCH 60/65] =?UTF-8?q?fix(TimeBlockController):=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=83=9C=EA=B7=B8=20=EC=82=AD=EC=A0=9C=20api=20url?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiki/server/timeblock/controller/TimeBlockController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java index fd79e47d..981f9bbe 100644 --- a/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java +++ b/src/main/java/com/tiki/server/timeblock/controller/TimeBlockController.java @@ -105,7 +105,7 @@ public SuccessResponse createDocumentTag( } @ResponseStatus(HttpStatus.NO_CONTENT) - @DeleteMapping("/teams/{teamId}/time-block/{timeBlockId}") + @DeleteMapping("/teams/{teamId}/time-block/{timeBlockId}/tags") public SuccessResponse deleteDocumentTag( final Principal principal, @PathVariable final long teamId, From 197e55956100633916ddbc50d4c96f0fc7e513b3 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Wed, 11 Dec 2024 19:51:04 +0900 Subject: [PATCH 61/65] =?UTF-8?q?fix:=20s3=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=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 +- .../com/tiki/server/external/dto/request/S3DeleteRequest.java | 2 +- src/main/java/com/tiki/server/external/service/S3Service.java | 2 +- 3 files changed, 3 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 f6c8ee1b..3781c200 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -82,7 +82,7 @@ public void deleteTrash(final long memberId, final long teamId, final List memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); List deletedDocuments = deletedDocumentAdapter.get(documentIds, teamId); restoreTeamUsage(teamId, deletedDocuments); - deletedDocuments.forEach(deletedDocument -> s3Handler.deleteFile(deletedDocument.getFileName())); + deletedDocuments.forEach(deletedDocument -> s3Handler.deleteFile(deletedDocument.getFileKey())); deletedDocumentAdapter.deleteAll(deletedDocuments); } diff --git a/src/main/java/com/tiki/server/external/dto/request/S3DeleteRequest.java b/src/main/java/com/tiki/server/external/dto/request/S3DeleteRequest.java index ea68a69c..7904f7cb 100644 --- a/src/main/java/com/tiki/server/external/dto/request/S3DeleteRequest.java +++ b/src/main/java/com/tiki/server/external/dto/request/S3DeleteRequest.java @@ -3,6 +3,6 @@ import lombok.NonNull; public record S3DeleteRequest( - @NonNull String fileName + @NonNull String fileKey ) { } diff --git a/src/main/java/com/tiki/server/external/service/S3Service.java b/src/main/java/com/tiki/server/external/service/S3Service.java index 4cded7b7..444c3feb 100644 --- a/src/main/java/com/tiki/server/external/service/S3Service.java +++ b/src/main/java/com/tiki/server/external/service/S3Service.java @@ -17,6 +17,6 @@ public PreSignedUrlResponse getUploadPreSignedUrl(final String fileFormat) { } public void deleteFile(final S3DeleteRequest request) { - s3Handler.deleteFile(request.fileName()); + s3Handler.deleteFile(request.fileKey()); } } From 9894a9d79c62e800dfd95ef694eca18c73af502b Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 12 Dec 2024 16:12:17 +0900 Subject: [PATCH 62/65] =?UTF-8?q?fix(DocumentControllerDocs):=20=EC=8A=A4?= =?UTF-8?q?=EC=9B=A8=EA=B1=B0=20url=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0?= =?UTF-8?q?=20=EB=A7=A4=ED=95=91=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docs/DocumentControllerDocs.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/tiki/server/document/controller/docs/DocumentControllerDocs.java b/src/main/java/com/tiki/server/document/controller/docs/DocumentControllerDocs.java index 7ef0937a..b9f6a5f8 100644 --- a/src/main/java/com/tiki/server/document/controller/docs/DocumentControllerDocs.java +++ b/src/main/java/com/tiki/server/document/controller/docs/DocumentControllerDocs.java @@ -81,13 +81,13 @@ ResponseEntity> getAllDocuments( ResponseEntity> createDocuments( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "폴더 id", + name = "folderId", description = "생성할 파일이 속할 폴더 id", in = ParameterIn.QUERY, example = "1" @@ -112,13 +112,13 @@ ResponseEntity> createDocuments( ResponseEntity> getDocuments( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "폴더 id", + name = "folderId", description = "조회할 폴더 id", in = ParameterIn.QUERY, example = "1" @@ -142,13 +142,13 @@ ResponseEntity> getDocuments( ResponseEntity delete( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "파일 id", + name = "documentId", description = "삭제할 파일 id 리스트", in = ParameterIn.QUERY, required = true, @@ -173,13 +173,13 @@ ResponseEntity delete( ResponseEntity deleteTrash( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "파일 id", + name = "documentId", description = "삭제할 파일 id 리스트", in = ParameterIn.QUERY, required = true, @@ -204,13 +204,13 @@ ResponseEntity deleteTrash( ResponseEntity restore( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "파일 id", + name = "documentId", description = "복구할 파일 id 리스트", in = ParameterIn.QUERY, required = true, @@ -235,7 +235,7 @@ ResponseEntity restore( ResponseEntity> getTrash( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" From dc0ef5627b0c8979c11bcd4830d309eb271830c2 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 12 Dec 2024 16:13:33 +0900 Subject: [PATCH 63/65] =?UTF-8?q?fix(FolderControllerDocs):=20=EC=8A=A4?= =?UTF-8?q?=EC=9B=A8=EA=B1=B0=20url=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0?= =?UTF-8?q?=20=EB=A7=A4=ED=95=91=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/docs/FolderControllerDocs.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/tiki/server/folder/controller/docs/FolderControllerDocs.java b/src/main/java/com/tiki/server/folder/controller/docs/FolderControllerDocs.java index 57086748..20c62c3c 100644 --- a/src/main/java/com/tiki/server/folder/controller/docs/FolderControllerDocs.java +++ b/src/main/java/com/tiki/server/folder/controller/docs/FolderControllerDocs.java @@ -42,13 +42,13 @@ public interface FolderControllerDocs { ResponseEntity> getFolders( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "폴더 id", + name = "folderId", description = "조회할 폴더 id", in = ParameterIn.QUERY, example = "1" @@ -72,13 +72,13 @@ ResponseEntity> getFolders( ResponseEntity> createFolder( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "폴더 id", + name = "folderId", description = "생성할 폴더가 속할 폴더 id", in = ParameterIn.QUERY, example = "1" @@ -103,13 +103,13 @@ ResponseEntity> createFolder( ResponseEntity> updateFolderName( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "폴더 id", + name = "folderId", description = "수정할 폴더 id", in = ParameterIn.PATH, example = "1" @@ -134,13 +134,13 @@ ResponseEntity> updateFolderName( ResponseEntity delete( @Parameter(hidden = true) Principal principal, @Parameter( - name = "팀 id", + name = "teamId", description = "팀 id", in = ParameterIn.PATH, example = "1" ) @PathVariable long teamId, @Parameter( - name = "폴더 id", + name = "folderId", description = "삭제할 폴더 id 리스트", in = ParameterIn.QUERY, required = true, From e62f596eccabfd102d4f94cca93ca83cd8796398 Mon Sep 17 00:00:00 2001 From: Chan531 Date: Thu, 12 Dec 2024 16:17:45 +0900 Subject: [PATCH 64/65] =?UTF-8?q?feat(TimeBlockControllerDocs):=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=ED=83=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=82=AD=EC=A0=9C=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docs/TimeBlockControllerDocs.java | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/main/java/com/tiki/server/timeblock/controller/docs/TimeBlockControllerDocs.java b/src/main/java/com/tiki/server/timeblock/controller/docs/TimeBlockControllerDocs.java index 13023a62..6cff82ec 100644 --- a/src/main/java/com/tiki/server/timeblock/controller/docs/TimeBlockControllerDocs.java +++ b/src/main/java/com/tiki/server/timeblock/controller/docs/TimeBlockControllerDocs.java @@ -1,6 +1,7 @@ package com.tiki.server.timeblock.controller.docs; import java.security.Principal; +import java.util.List; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -200,4 +201,80 @@ ResponseEntity deleteTimeBlock( ) @PathVariable long timeBlockId ); + + @Operation( + summary = "타임 블록 파일 태그 추가", + description = "타임 블록에 파일 태그를 추가한다.", + responses = { + @ApiResponse(responseCode = "201", description = "성공"), + @ApiResponse( + responseCode = "4xx", + description = "클라이언트(요청) 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)))} + ) + SuccessResponse createDocumentTag( + @Parameter(hidden = true) Principal principal, + @Parameter( + name = "teamId", + description = "팀 id", + in = ParameterIn.PATH, + example = "1" + ) @PathVariable long teamId, + @Parameter( + name = "timeBlockId", + description = "타임 블록 id", + in = ParameterIn.PATH, + example = "1" + ) @PathVariable long timeBlockId, + @Parameter( + name = "documentId", + description = "추가할 파일 id 리스트", + in = ParameterIn.QUERY, + required = true, + example = "[1, 2]" + ) @RequestParam("documentId") List documentIds + ); + + @Operation( + summary = "타임 블록 파일 태그 삭제", + description = "타임 블록의 파일 태그를 삭제한다.", + responses = { + @ApiResponse(responseCode = "204", description = "성공"), + @ApiResponse( + responseCode = "4xx", + description = "클라이언트(요청) 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)))} + ) + SuccessResponse deleteDocumentTag( + @Parameter(hidden = true) Principal principal, + @Parameter( + name = "teamId", + description = "팀 id", + in = ParameterIn.PATH, + example = "1" + ) + @PathVariable long teamId, + @Parameter( + name = "timeBlockId", + description = "타임 블록 id", + in = ParameterIn.PATH, + example = "1" + ) + @PathVariable long timeBlockId, + @Parameter( + name = "tagId", + description = "삭제할 파일 태그 id 리스트", + in = ParameterIn.QUERY, + required = true, + example = "[1, 2]" + ) @RequestParam("tagId") List tagIds + ); } From 0433a9fb214f3f8b1a744580bd6d0d2ddf42bd2a Mon Sep 17 00:00:00 2001 From: Chan531 Date: Fri, 13 Dec 2024 15:53:44 +0900 Subject: [PATCH 65/65] =?UTF-8?q?delete:=20=EC=A3=BC=EC=84=9D=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=A9=94=EC=86=8C=EB=93=9C=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/adapter/DocumentFinder.java | 4 ---- .../tiki/server/document/repository/DocumentRepository.java | 4 ---- .../com/tiki/server/document/service/DocumentService.java | 5 ----- 3 files changed, 13 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 acf7a7dc..772db6d3 100644 --- a/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java +++ b/src/main/java/com/tiki/server/document/adapter/DocumentFinder.java @@ -28,10 +28,6 @@ public Document findById(final long documentId) { .orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); } - // public List findAllByTeamIdAndAccessiblePosition(long teamId, Position accessiblePosition) { - // return documentRepository.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); - // } - public List findAllByTeamId(long teamId) { return documentRepository.findAllByTeamId(teamId); } 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 97cb8a88..8013da3c 100644 --- a/src/main/java/com/tiki/server/document/repository/DocumentRepository.java +++ b/src/main/java/com/tiki/server/document/repository/DocumentRepository.java @@ -12,10 +12,6 @@ public interface DocumentRepository extends JpaRepository { 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); - List findAllByTeamId(long teamId); List findAllByTeamIdAndFolderIdOrderByCreatedAtDesc(long teamId, Long folderId); 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 3781c200..9c1020e4 100644 --- a/src/main/java/com/tiki/server/document/service/DocumentService.java +++ b/src/main/java/com/tiki/server/document/service/DocumentService.java @@ -100,11 +100,6 @@ public DeletedDocumentsGetResponse getTrash(final long memberId, final long team return DeletedDocumentsGetResponse.from(deletedDocuments); } - // private DocumentsGetResponse getAllDocumentsByType(final long teamId, final Position accessiblePosition) { - // List documents = documentFinder.findAllByTeamIdAndAccessiblePosition(teamId, accessiblePosition); - // return DocumentsGetResponse.from(documents); - // } - private void validateFolder(final Long folderId, final long teamId) { if (folderId == null) { return;