From e6280c0b67a041161593fbb05b758677dd406da5 Mon Sep 17 00:00:00 2001 From: "2jin2.1031" <2jin2.1031@gmail.com> Date: Tue, 10 Mar 2026 14:28:24 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EC=A1=B0=EC=A7=81=20=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=EB=A5=BC=20=EC=A1=B0=ED=9A=8C=ED=95=A0=20=EB=95=8C=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0=EB=90=9C=20=ED=81=AC=EB=A3=A8=20=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EB=AA=A9=EB=A1=9D=EB=8F=84=20=ED=95=A8=EA=BB=98=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=EC=9D=84=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/LinkedCrewDocumentResponse.java | 17 +++++++++++++++++ .../OrganizationDocumentAndEventResponse.java | 8 +++++--- .../DocumentOrganizationLinkRepository.java | 2 ++ .../service/OrganizationDocumentService.java | 10 +++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/wooteco/wiki/organizationdocument/dto/response/LinkedCrewDocumentResponse.java diff --git a/src/main/java/com/wooteco/wiki/organizationdocument/dto/response/LinkedCrewDocumentResponse.java b/src/main/java/com/wooteco/wiki/organizationdocument/dto/response/LinkedCrewDocumentResponse.java new file mode 100644 index 0000000..23d7425 --- /dev/null +++ b/src/main/java/com/wooteco/wiki/organizationdocument/dto/response/LinkedCrewDocumentResponse.java @@ -0,0 +1,17 @@ +package com.wooteco.wiki.organizationdocument.dto.response; + +import com.wooteco.wiki.document.domain.CrewDocument; +import java.util.UUID; + +public record LinkedCrewDocumentResponse( + UUID documentUuid, + String title +) { + + public LinkedCrewDocumentResponse(CrewDocument crewDocument) { + this( + crewDocument.getUuid(), + crewDocument.getTitle() + ); + } +} \ No newline at end of file diff --git a/src/main/java/com/wooteco/wiki/organizationdocument/dto/response/OrganizationDocumentAndEventResponse.java b/src/main/java/com/wooteco/wiki/organizationdocument/dto/response/OrganizationDocumentAndEventResponse.java index eddb117..faf79ff 100644 --- a/src/main/java/com/wooteco/wiki/organizationdocument/dto/response/OrganizationDocumentAndEventResponse.java +++ b/src/main/java/com/wooteco/wiki/organizationdocument/dto/response/OrganizationDocumentAndEventResponse.java @@ -14,13 +14,15 @@ public record OrganizationDocumentAndEventResponse( String contents, String writer, LocalDateTime generateTime, - List organizationEventResponses + List organizationEventResponses, + List linkedCrewDocuments ) { public OrganizationDocumentAndEventResponse( OrganizationDocument organizationDocument, - List organizationEventResponses + List organizationEventResponses, + List linkedCrewDocuments ) { - this(organizationDocument.getId(), organizationDocument.getUuid(), organizationDocument.getTitle(), organizationDocument.getContents(), organizationDocument.getWriter(), organizationDocument.getGenerateTime(), organizationEventResponses); + this(organizationDocument.getId(), organizationDocument.getUuid(), organizationDocument.getTitle(), organizationDocument.getContents(), organizationDocument.getWriter(), organizationDocument.getGenerateTime(), organizationEventResponses, linkedCrewDocuments); } } diff --git a/src/main/java/com/wooteco/wiki/organizationdocument/repository/DocumentOrganizationLinkRepository.java b/src/main/java/com/wooteco/wiki/organizationdocument/repository/DocumentOrganizationLinkRepository.java index 5d6b498..0eaa575 100644 --- a/src/main/java/com/wooteco/wiki/organizationdocument/repository/DocumentOrganizationLinkRepository.java +++ b/src/main/java/com/wooteco/wiki/organizationdocument/repository/DocumentOrganizationLinkRepository.java @@ -19,5 +19,7 @@ void deleteByCrewDocumentAndOrganizationDocument(CrewDocument crewDocument, List findAllByCrewDocument(CrewDocument crewDocument); + List findAllByOrganizationDocument(OrganizationDocument organizationDocument); + void deleteAllByCrewDocument(CrewDocument crewDocument); } diff --git a/src/main/java/com/wooteco/wiki/organizationdocument/service/OrganizationDocumentService.java b/src/main/java/com/wooteco/wiki/organizationdocument/service/OrganizationDocumentService.java index 7075111..0a46844 100644 --- a/src/main/java/com/wooteco/wiki/organizationdocument/service/OrganizationDocumentService.java +++ b/src/main/java/com/wooteco/wiki/organizationdocument/service/OrganizationDocumentService.java @@ -12,8 +12,10 @@ import com.wooteco.wiki.organizationdocument.dto.request.OrganizationDocumentCreateRequest; import com.wooteco.wiki.organizationdocument.dto.request.OrganizationDocumentLinkRequest; import com.wooteco.wiki.organizationdocument.dto.request.OrganizationDocumentUpdateRequest; +import com.wooteco.wiki.organizationdocument.dto.response.LinkedCrewDocumentResponse; import com.wooteco.wiki.organizationdocument.dto.response.OrganizationDocumentAndEventResponse; import com.wooteco.wiki.organizationdocument.dto.response.OrganizationDocumentResponse; +import com.wooteco.wiki.organizationdocument.repository.DocumentOrganizationLinkRepository; import com.wooteco.wiki.organizationdocument.repository.OrganizationDocumentRepository; import com.wooteco.wiki.organizationevent.dto.response.OrganizationEventResponse; import com.wooteco.wiki.organizationevent.repository.OrganizationEventRepository; @@ -33,6 +35,7 @@ public class OrganizationDocumentService { private final OrganizationEventRepository organizationEventRepository; private final DocumentRepository documentRepository; private final DocumentOrganizationLinkService documentOrganizationLinkService; + private final DocumentOrganizationLinkRepository documentOrganizationLinkRepository; private final CrewDocumentRepository crewDocumentRepository; private final HistoryService historyService; @@ -80,7 +83,12 @@ public OrganizationDocumentAndEventResponse findByUuid(UUID uuidText) { .stream() .map(OrganizationEventResponse::new) .toList(); - return new OrganizationDocumentAndEventResponse(organizationDocument, organizationEventResponses); + List linkedCrewDocuments = documentOrganizationLinkRepository.findAllByOrganizationDocument( + organizationDocument) + .stream() + .map(link -> new LinkedCrewDocumentResponse(link.getCrewDocument())) + .toList(); + return new OrganizationDocumentAndEventResponse(organizationDocument, organizationEventResponses, linkedCrewDocuments); } private CrewDocument getCrewDocument(UUID uuid) { From 8daa3f636f87da4a144d82c1f46723f50abbc49d Mon Sep 17 00:00:00 2001 From: "2jin2.1031" <2jin2.1031@gmail.com> Date: Wed, 11 Mar 2026 16:17:22 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EC=A1=B0=EC=A7=81=20=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=EC=99=80=20=EC=97=B0=EA=B2=B0=EB=90=9C=20=ED=81=AC?= =?UTF-8?q?=EB=A3=A8=20=EB=AC=B8=EC=84=9C=20=EC=A1=B0=ED=9A=8C=20=EB=B0=A9?= =?UTF-8?q?=EC=8B=9D=EC=9D=84=20fetch=20join=EC=9C=BC=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/DocumentOrganizationLinkRepository.java | 8 +++++++- .../service/OrganizationDocumentService.java | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/wooteco/wiki/organizationdocument/repository/DocumentOrganizationLinkRepository.java b/src/main/java/com/wooteco/wiki/organizationdocument/repository/DocumentOrganizationLinkRepository.java index 0eaa575..9b4f16f 100644 --- a/src/main/java/com/wooteco/wiki/organizationdocument/repository/DocumentOrganizationLinkRepository.java +++ b/src/main/java/com/wooteco/wiki/organizationdocument/repository/DocumentOrganizationLinkRepository.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface DocumentOrganizationLinkRepository extends JpaRepository { @@ -19,7 +21,11 @@ void deleteByCrewDocumentAndOrganizationDocument(CrewDocument crewDocument, List findAllByCrewDocument(CrewDocument crewDocument); - List findAllByOrganizationDocument(OrganizationDocument organizationDocument); + @Query("SELECT documentOrganizationLink FROM DocumentOrganizationLink documentOrganizationLink " + + "JOIN FETCH documentOrganizationLink.crewDocument " + + "WHERE documentOrganizationLink.organizationDocument = :organizationDocument") + List findAllByOrganizationDocumentWithCrewDocument( + @Param("organizationDocument") OrganizationDocument organizationDocument); void deleteAllByCrewDocument(CrewDocument crewDocument); } diff --git a/src/main/java/com/wooteco/wiki/organizationdocument/service/OrganizationDocumentService.java b/src/main/java/com/wooteco/wiki/organizationdocument/service/OrganizationDocumentService.java index 0a46844..05f47cb 100644 --- a/src/main/java/com/wooteco/wiki/organizationdocument/service/OrganizationDocumentService.java +++ b/src/main/java/com/wooteco/wiki/organizationdocument/service/OrganizationDocumentService.java @@ -83,8 +83,8 @@ public OrganizationDocumentAndEventResponse findByUuid(UUID uuidText) { .stream() .map(OrganizationEventResponse::new) .toList(); - List linkedCrewDocuments = documentOrganizationLinkRepository.findAllByOrganizationDocument( - organizationDocument) + List linkedCrewDocuments = documentOrganizationLinkRepository + .findAllByOrganizationDocumentWithCrewDocument(organizationDocument) .stream() .map(link -> new LinkedCrewDocumentResponse(link.getCrewDocument())) .toList();