From fd272913cd2b1f4cb2a3462f6ea2ac5975035fe1 Mon Sep 17 00:00:00 2001 From: Sejeong Kim <64718002+clean2001@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:20:16 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EC=8B=A4=ED=96=89=20=EB=AA=A9?= =?UTF-8?q?=ED=91=9C=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD,=20=EB=A6=AC=EB=B7=B0=20=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=20(#139)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 실행 목표가 없는 회고 응답에서 제외 * chore: dto 이름 변경 * chore: 새로운 폼 저장 title ->formName으로 변경 --- .../actionItem/controller/ActionItemApi.java | 8 +- .../controller/ActionItemController.java | 26 +++--- ...uest.java => ActionItemCreateRequest.java} | 2 +- .../dto/MemberActionItemElementResponse.java | 51 ------------ .../dto/MemberActionItemGetResponse.java | 8 ++ .../dto/MemberActionItemResponse.java | 29 ++++++- ...e.java => SpaceActionItemGetResponse.java} | 6 +- ...SpaceRetrospectActionItemGetResponse.java} | 6 +- .../actionItem/service/ActionItemService.java | 82 ++++++++++--------- .../retrospect/service/RetrospectService.java | 8 +- .../domain/actionItem/entity/ActionItem.java | 3 - .../repository/ActionItemRepository.java | 2 +- .../space/repository/SpaceRepository.java | 5 +- 13 files changed, 110 insertions(+), 126 deletions(-) rename layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/{CreateActionItemRequest.java => ActionItemCreateRequest.java} (92%) delete mode 100644 layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemElementResponse.java create mode 100644 layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemGetResponse.java rename layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/{GetSpaceActionItemResponse.java => SpaceActionItemGetResponse.java} (89%) rename layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/{GetSpaceRetrospectActionItemResponse.java => SpaceRetrospectActionItemGetResponse.java} (85%) diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemApi.java b/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemApi.java index 068e89fb..521a816e 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemApi.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemApi.java @@ -23,7 +23,7 @@ public interface ActionItemApi { } ) ResponseEntity createActionItem(@MemberId Long memberId, - @Validated @RequestBody CreateActionItemRequest createActionItemRequest); + @Validated @RequestBody ActionItemCreateRequest actionItemCreateRequest); @Operation(summary = "개인의 액션 아이템 조회", method = "GET", description = """ @@ -40,7 +40,7 @@ ResponseEntity createActionItem(@MemberId Long memberId, ) } ) - ResponseEntity memberActionItem(@MemberId Long currentMemberId); + ResponseEntity memberActionItem(@MemberId Long currentMemberId); @Operation(summary = "팀의 액션 아이템 조회", method = "GET", description = """ 팀 아이디로 팀의 모든 액션아이템을 회고 별로 조회합니다. @@ -57,7 +57,7 @@ ResponseEntity createActionItem(@MemberId Long memberId, ) } ) - ResponseEntity teamActionItem(@MemberId Long memberId, + ResponseEntity teamActionItem(@MemberId Long memberId, @PathVariable Long spaceId); @@ -76,7 +76,7 @@ ResponseEntity teamActionItem(@MemberId Lo ) } ) - ResponseEntity spaceRecentActionItem(@MemberId Long memberId, + ResponseEntity spaceRecentActionItem(@MemberId Long memberId, @PathVariable Long spaceId); @Operation(summary = "액션 아이템 삭제", method = "DELETE", description = """ diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemController.java b/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemController.java index 4c6a3ca4..f3e41574 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemController.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemController.java @@ -3,10 +3,10 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.layer.common.annotation.MemberId; -import org.layer.domain.actionItem.controller.dto.CreateActionItemRequest; -import org.layer.domain.actionItem.controller.dto.MemberActionItemResponse; -import org.layer.domain.actionItem.controller.dto.GetSpaceActionItemResponse; -import org.layer.domain.actionItem.controller.dto.GetSpaceRetrospectActionItemResponse; +import org.layer.domain.actionItem.controller.dto.ActionItemCreateRequest; +import org.layer.domain.actionItem.controller.dto.MemberActionItemGetResponse; +import org.layer.domain.actionItem.controller.dto.SpaceActionItemGetResponse; +import org.layer.domain.actionItem.controller.dto.SpaceRetrospectActionItemGetResponse; import org.layer.domain.actionItem.service.ActionItemService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -24,10 +24,10 @@ public class ActionItemController implements ActionItemApi { @PostMapping("/create") @PreAuthorize("isAuthenticated()") public ResponseEntity createActionItem(@MemberId Long memberId, - @Validated @RequestBody CreateActionItemRequest createActionItemRequest) { + @Validated @RequestBody ActionItemCreateRequest actionItemCreateRequest) { actionItemService.createActionItem(memberId, - createActionItemRequest.retrospectId(), - createActionItemRequest.content()); + actionItemCreateRequest.retrospectId(), + actionItemCreateRequest.content()); return new ResponseEntity<>(null, HttpStatus.CREATED); } @@ -35,24 +35,24 @@ public ResponseEntity createActionItem(@MemberId Long memberId, @Override @GetMapping("/member") @PreAuthorize("isAuthenticated()") - public ResponseEntity memberActionItem(@MemberId Long currentMemberId) { - MemberActionItemResponse memberActionItems = actionItemService.getMemberActionItemList(currentMemberId); + public ResponseEntity memberActionItem(@MemberId Long currentMemberId) { + MemberActionItemGetResponse memberActionItems = actionItemService.getMemberActionItemList(currentMemberId); return new ResponseEntity<>(memberActionItems, HttpStatus.OK); } @Override @GetMapping("/space/{spaceId}") @PreAuthorize("isAuthenticated()") - public ResponseEntity teamActionItem(@MemberId Long memberId, @PathVariable(name = "spaceId") Long spaceId) { - GetSpaceRetrospectActionItemResponse teamActionItem = actionItemService.getSpaceActionItemList(memberId, spaceId); + public ResponseEntity teamActionItem(@MemberId Long memberId, @PathVariable(name = "spaceId") Long spaceId) { + SpaceRetrospectActionItemGetResponse teamActionItem = actionItemService.getSpaceActionItemList(memberId, spaceId); return new ResponseEntity<>(teamActionItem, HttpStatus.OK); } @Override @GetMapping("/space/{spaceId}/recent") - public ResponseEntity spaceRecentActionItem(@MemberId Long memberId, @PathVariable(name = "spaceId") Long spaceId) { - GetSpaceActionItemResponse spaceRecentActionItems = actionItemService.getSpaceRecentActionItems(memberId, spaceId); + public ResponseEntity spaceRecentActionItem(@MemberId Long memberId, @PathVariable(name = "spaceId") Long spaceId) { + SpaceActionItemGetResponse spaceRecentActionItems = actionItemService.getSpaceRecentActionItems(memberId, spaceId); return new ResponseEntity<>(spaceRecentActionItems, HttpStatus.OK); } diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/CreateActionItemRequest.java b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/ActionItemCreateRequest.java similarity index 92% rename from layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/CreateActionItemRequest.java rename to layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/ActionItemCreateRequest.java index 8ca09ce6..82548819 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/CreateActionItemRequest.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/ActionItemCreateRequest.java @@ -4,7 +4,7 @@ import jakarta.validation.constraints.NotNull; @Schema(description = "액션 아이템 생성 요정") -public record CreateActionItemRequest(@NotNull +public record ActionItemCreateRequest(@NotNull @Schema(description = "액션 아이템과 매핑되는 회고 ID") Long retrospectId, @NotNull diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemElementResponse.java b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemElementResponse.java deleted file mode 100644 index 3c9754bb..00000000 --- a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemElementResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.layer.domain.actionItem.controller.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; -import lombok.Builder; -import org.layer.domain.actionItem.entity.ActionItem; -import org.layer.domain.actionItem.enums.ActionItemStatus; -import org.layer.domain.retrospect.entity.Retrospect; -import org.layer.domain.space.entity.Space; - -@Builder -public record MemberActionItemElementResponse( - @NotNull - @Schema(description = "실행 목표가 속한 스페이스 ID") - Long spaceId, - @NotNull - @Schema(description = "실행 목표가 속한 스페이스 이름") - String spaceName, - @NotNull - @Schema(description = "실행 목표가 속한 회고 ID") - Long retrospectId, - @NotNull - @Schema(description = "실행 목표가 속한 회고 이름") - String retrospectTitle, - @NotNull - @Schema(description = "실행 목표 ID", examples = {"1", "2"}) - Long actionItemId, - @NotNull - @Schema(description = "실행 목표 내용", examples = {"긴 회의 시간 줄이기", "회의 후 내용 꼭 기록해두기"}) - String content, - @NotNull - @Schema(description = "핀 여부", examples = {"Y", "N"}) - String isPinned, - @NotNull - @Schema(description = "실행 목표 상태", examples = {"PROCEEDING", "BEFORE_START", "DONE"}) - ActionItemStatus actionItemStatus -) { - - public static MemberActionItemElementResponse of(Space space, Retrospect retrospect, ActionItem actionItem) { - return MemberActionItemElementResponse.builder() - .spaceId(space.getId()) - .spaceName(space.getName()) - .retrospectId(retrospect.getId()) - .retrospectTitle(retrospect.getTitle()) - .actionItemId(actionItem.getId()) - .content(actionItem.getContent()) - .isPinned(actionItem.getIsPinned() ? "Y" : "N") - .actionItemStatus(actionItem.getActionItemStatus()) - .build(); - } -} \ No newline at end of file diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemGetResponse.java b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemGetResponse.java new file mode 100644 index 00000000..587ad04b --- /dev/null +++ b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemGetResponse.java @@ -0,0 +1,8 @@ +package org.layer.domain.actionItem.controller.dto; + +import jakarta.validation.constraints.NotNull; + +import java.util.List; + +public record MemberActionItemGetResponse(@NotNull List actionItems) { +} diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemResponse.java b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemResponse.java index 644693e2..89300c9e 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemResponse.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/MemberActionItemResponse.java @@ -1,9 +1,36 @@ package org.layer.domain.actionItem.controller.dto; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Builder; +import org.layer.domain.retrospect.entity.Retrospect; +import org.layer.domain.space.entity.Space; import java.util.List; @Builder -public record MemberActionItemResponse(List actionItemResponse) { +public record MemberActionItemResponse(@NotNull + @Schema(description = "회고 ID", example = "1") + Long retrospectId, + @NotNull + @Schema(description = "회고 제목", example = "중간 발표 이후 회고") + String retrospectTitle, + @NotNull + @Schema(description = "회고가 속한 스페이스 ID", example = "1") + Long spaceId, + @NotNull + @Schema(description = "회고가 속한 스페이스 이름", example = "떡잎방범대") + String spaceName, + @NotNull + @Schema(description = "액션 아이템 아이디와 내용 리스트") + List actionItemList) { + public static MemberActionItemResponse of(Space space, Retrospect retrospect, List actionItemList) { + return MemberActionItemResponse.builder() + .retrospectId(retrospect.getId()) + .retrospectTitle(retrospect.getTitle()) + .spaceId(space.getId()) + .spaceName(space.getName()) + .actionItemList(actionItemList) + .build(); + } } diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/GetSpaceActionItemResponse.java b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/SpaceActionItemGetResponse.java similarity index 89% rename from layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/GetSpaceActionItemResponse.java rename to layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/SpaceActionItemGetResponse.java index edd31805..10df8326 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/GetSpaceActionItemResponse.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/SpaceActionItemGetResponse.java @@ -10,7 +10,7 @@ import java.util.List; @Builder -public record GetSpaceActionItemResponse(@NotNull +public record SpaceActionItemGetResponse(@NotNull @Schema(description = "액션 아이템이 속한 스페이스 ID") Long spaceId, @NotNull @@ -21,12 +21,12 @@ public record GetSpaceActionItemResponse(@NotNull List teamActionItemList ) { - public static GetSpaceActionItemResponse of(Space space, Retrospect retrospect, List spaceActionItemList) { + public static SpaceActionItemGetResponse of(Space space, Retrospect retrospect, List spaceActionItemList) { List actionItemElements = spaceActionItemList.stream() .map(a -> SpaceActionItemElementResponse.of(a, retrospect)) .toList(); - return GetSpaceActionItemResponse.builder() + return SpaceActionItemGetResponse.builder() .spaceId(space.getId()) .spaceName(space.getName()) .teamActionItemList(actionItemElements) diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/GetSpaceRetrospectActionItemResponse.java b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/SpaceRetrospectActionItemGetResponse.java similarity index 85% rename from layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/GetSpaceRetrospectActionItemResponse.java rename to layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/SpaceRetrospectActionItemGetResponse.java index e1aeba24..cd633054 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/GetSpaceRetrospectActionItemResponse.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/controller/dto/SpaceRetrospectActionItemGetResponse.java @@ -8,7 +8,7 @@ import java.util.List; @Builder -public record GetSpaceRetrospectActionItemResponse(@NotNull +public record SpaceRetrospectActionItemGetResponse(@NotNull @Schema(description = "액션 아이템이 속한 스페이스 ID") Long spaceId, @NotNull @@ -19,8 +19,8 @@ public record GetSpaceRetrospectActionItemResponse(@NotNull List teamActionItemList ) { - public static GetSpaceRetrospectActionItemResponse of(Space space, List actionItemList) { - return GetSpaceRetrospectActionItemResponse.builder() + public static SpaceRetrospectActionItemGetResponse of(Space space, List actionItemList) { + return SpaceRetrospectActionItemGetResponse.builder() .spaceId(space.getId()) .spaceName(space.getName()) .teamActionItemList(actionItemList) diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/service/ActionItemService.java b/layer-api/src/main/java/org/layer/domain/actionItem/service/ActionItemService.java index 73c880cb..b06afb69 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/service/ActionItemService.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/service/ActionItemService.java @@ -44,6 +44,7 @@ public void createActionItem(Long memberId, Long retrospectId, String content) { throw new MemberSpaceRelationException(NOT_FOUND_MEMBER_SPACE_RELATION); } + // 액션 아이템 생성 actionItemRepository.save(ActionItem.builder() .retrospectId(retrospectId) @@ -55,7 +56,8 @@ public void createActionItem(Long memberId, Long retrospectId, String content) { } - public GetSpaceRetrospectActionItemResponse getSpaceActionItemList(Long memberId, Long spaceId) { + //== 스페이스의 액션 아이템 조회 ==// + public SpaceRetrospectActionItemGetResponse getSpaceActionItemList(Long memberId, Long spaceId) { // space가 존재하는지 확인 Space space = spaceRepository.findByIdOrThrow(spaceId); @@ -75,6 +77,12 @@ public GetSpaceRetrospectActionItemResponse getSpaceActionItemList(Long memberId List response = new ArrayList<>(); for (Retrospect doneRetrospect : doneRetrospects) { List actionItems = actionItemRepository.findAllByRetrospectId(doneRetrospect.getId()); + + // 액션 아이템이 없는 회고는 응답에서 제외 + if(actionItems.isEmpty()) { + continue; + } + List actionItemResponses = actionItems.stream() .map(ActionItemResponse::of) .toList(); @@ -88,7 +96,7 @@ public GetSpaceRetrospectActionItemResponse getSpaceActionItemList(Long memberId response.add(responseElement); } - return GetSpaceRetrospectActionItemResponse.of(space, response); + return SpaceRetrospectActionItemGetResponse.of(space, response); } @Transactional @@ -99,8 +107,8 @@ public void deleteActionItem(Long memberId, Long actionItemId) { actionItemRepository.delete(actionItem); } - // space에서 모든 끝난 회고에 대한 실행 목표 조회 - public GetSpaceActionItemResponse getSpaceRecentActionItems(Long memberId, Long spaceId) { + //== space에서 가장 최근에 끝난 회고에 대한 실행 목표 조회 ==// + public SpaceActionItemGetResponse getSpaceRecentActionItems(Long memberId, Long spaceId) { // 스페이스가 있는지 검증 Space space = spaceRepository.findByIdOrThrow(spaceId); @@ -118,50 +126,48 @@ public GetSpaceActionItemResponse getSpaceRecentActionItems(Long memberId, Long if(recentOpt.isPresent()) { Retrospect recent = recentOpt.get(); List actionItems = actionItemRepository.findAllByRetrospectId(recent.getId()); - return GetSpaceActionItemResponse.of(space, recent, actionItems); + + return SpaceActionItemGetResponse.of(space, recent, actionItems); } - return null; + + // DONE인 회고가 없는 경우 + return SpaceActionItemGetResponse.of(space, null, new ArrayList<>()); } - public MemberActionItemResponse getMemberActionItemList(Long currentMemberId) { + //== 회원의 액션 아이템 조회 ==// + public MemberActionItemGetResponse getMemberActionItemList(Long currentMemberId) { // 멤버가 속한 스페이스 모두 가져오기 - List memberSpaceRelations = memberSpaceRelationRepository.findAllByMemberId(currentMemberId); - List spaces = memberSpaceRelations.stream().map(MemberSpaceRelation::getSpace).toList(); // TODO: N+1 쿼리 나갈것 같은데.. 함 봐야겠다 + List spaces = spaceRepository.findByMemberId(currentMemberId); - // 스페이스에서 상태가 Done인 회고 모두 가져오기 + // 끝난 회고 모두 찾기 (데드라인 내림차순) List spaceIds = spaces.stream().map(Space::getId).toList(); - List doneRetrospects = retrospectRepository.findAllBySpaceIdIn(spaceIds).stream() - .filter(s -> s.getRetrospectStatus().equals(DONE)) + List doneRetrospects = retrospectRepository.findAllBySpaceIdIn(spaceIds) + .stream() + .filter(retrospect -> retrospect.getRetrospectStatus().equals(DONE)) + .sorted((a, b) -> b.getDeadline().compareTo(a.getDeadline())) // 최근에 끝난 순으로 정렬 .toList(); - // 액션 아이템 모두 뽑아오기 - List idList = doneRetrospects.stream().map(Retrospect::getId).toList(); - List actionItemList = actionItemRepository.findAllByRetrospectIdIn(idList).stream() - .sorted((a, b) -> { - if(a.getIsPinned() && b.getIsPinned() - && a.getActionItemStatus().equals(b.getActionItemStatus())) { - return b.getCreatedAt().compareTo(a.getCreatedAt()); // 둘다 핀 돼있고, 상태도 같으면 최신 순 - } else if(a.getIsPinned() && b.getIsPinned()) { - return a.getActionItemStatus().getPriority() - b.getActionItemStatus().getPriority(); - } else if(a.getIsPinned() || b.getIsPinned()) { - return a.getIsPinned() ? -1 : 1; - } else if(!a.getActionItemStatus().equals(b.getActionItemStatus())) { - return a.getActionItemStatus().getPriority() - b.getActionItemStatus().getPriority(); - } else { - return b.getCreatedAt().compareTo(a.getCreatedAt()); // 둘다 핀 돼있고, proceeding 이면 최신 순 - } - }).toList(); - - List response = new ArrayList<>(); - for (ActionItem actionItem : actionItemList) { - Space space = spaceRepository.findByIdOrThrow(actionItem.getSpaceId()); - Retrospect retrospect = retrospectRepository.findByIdOrThrow(actionItem.getRetrospectId()); - - MemberActionItemElementResponse responseElement = MemberActionItemElementResponse.of(space, retrospect, actionItem); - response.add(responseElement); + + List responses = new ArrayList<>(); + for (Retrospect doneRetrospect : doneRetrospects) { + // 해당 회고에 관련한 실행 목표 가져오기 + List actionItems = actionItemRepository.findAllByRetrospectId(doneRetrospect.getId()); + + // 액션 아이템이 없는 회고는 응답에서 제외 + if(actionItems.isEmpty()) { + continue; + } + + List actionItemResponses = actionItems.stream() + .map(ActionItemResponse::of) + .toList(); + + // 회고가 어디 스페이스에 속하는지 찾기 + Space space = spaceRepository.findByIdOrThrow(doneRetrospect.getSpaceId()); + responses.add(MemberActionItemResponse.of(space, doneRetrospect, actionItemResponses)); } - return new MemberActionItemResponse(response); + return new MemberActionItemGetResponse(responses); } } diff --git a/layer-api/src/main/java/org/layer/domain/retrospect/service/RetrospectService.java b/layer-api/src/main/java/org/layer/domain/retrospect/service/RetrospectService.java index 14cc41fc..319c71ae 100644 --- a/layer-api/src/main/java/org/layer/domain/retrospect/service/RetrospectService.java +++ b/layer-api/src/main/java/org/layer/domain/retrospect/service/RetrospectService.java @@ -1,7 +1,6 @@ package org.layer.domain.retrospect.service; import lombok.RequiredArgsConstructor; - import org.layer.domain.answer.entity.Answers; import org.layer.domain.answer.repository.AnswerRepository; import org.layer.domain.common.time.Time; @@ -21,21 +20,16 @@ import org.layer.domain.retrospect.repository.RetrospectRepository; import org.layer.domain.retrospect.service.dto.response.RetrospectGetServiceResponse; import org.layer.domain.retrospect.service.dto.response.RetrospectListGetServiceResponse; -import org.layer.domain.space.entity.MemberSpaceRelation; import org.layer.domain.space.entity.Space; import org.layer.domain.space.entity.Team; -import org.layer.domain.space.exception.MemberSpaceRelationException; import org.layer.domain.space.repository.MemberSpaceRelationRepository; import org.layer.domain.space.repository.SpaceRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; -import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; -import static org.layer.common.exception.MemberSpaceRelationExceptionType.NOT_FOUND_MEMBER_SPACE_RELATION; - @Service @RequiredArgsConstructor @Transactional(readOnly = true) @@ -65,7 +59,7 @@ public Long createRetrospect(RetrospectCreateRequest request, Long spaceId, Long // 새로운 폼 생성(수정)인지 확인 if (request.isNewForm()) { // 내 회고 폼에 추가 - Form form = new Form(memberId, spaceId, request.title(), request.introduction(), FormType.CUSTOM, + Form form = new Form(memberId, spaceId, request.formName(), request.introduction(), FormType.CUSTOM, FormTag.CUSTOM); Form savedForm = formRepository.save(form); diff --git a/layer-domain/src/main/java/org/layer/domain/actionItem/entity/ActionItem.java b/layer-domain/src/main/java/org/layer/domain/actionItem/entity/ActionItem.java index c45afb5e..b5b0e41c 100644 --- a/layer-domain/src/main/java/org/layer/domain/actionItem/entity/ActionItem.java +++ b/layer-domain/src/main/java/org/layer/domain/actionItem/entity/ActionItem.java @@ -37,8 +37,6 @@ public class ActionItem extends BaseTimeEntity { @Enumerated(EnumType.STRING) private ActionItemStatus actionItemStatus; // 액션 아이템 상태 - @NotNull - Boolean isPinned; // 핀 돼있는지 @Builder private ActionItem(Long retrospectId, Long spaceId, Long memberId, String content, ActionItemStatus actionItemStatus, Boolean isPinned) { @@ -47,7 +45,6 @@ private ActionItem(Long retrospectId, Long spaceId, Long memberId, String conten this.memberId = memberId; this.content = content; this.actionItemStatus = actionItemStatus; - this.isPinned = isPinned; } public void isWriter(Long memberId) { diff --git a/layer-domain/src/main/java/org/layer/domain/actionItem/repository/ActionItemRepository.java b/layer-domain/src/main/java/org/layer/domain/actionItem/repository/ActionItemRepository.java index f6b7f401..77f3ff64 100644 --- a/layer-domain/src/main/java/org/layer/domain/actionItem/repository/ActionItemRepository.java +++ b/layer-domain/src/main/java/org/layer/domain/actionItem/repository/ActionItemRepository.java @@ -25,7 +25,7 @@ default ActionItem findByIdOrThrow(Long actionItemId) { List findAllByRetrospectId(Long retrospectId); List findAllByRetrospectIdIn(List retrospectId); - + @Modifying(clearAutomatically = true) @Transactional @Query("DELETE FROM ActionItem a WHERE a.spaceId = :spaceId") diff --git a/layer-domain/src/main/java/org/layer/domain/space/repository/SpaceRepository.java b/layer-domain/src/main/java/org/layer/domain/space/repository/SpaceRepository.java index e88c84e3..7bb4ee19 100644 --- a/layer-domain/src/main/java/org/layer/domain/space/repository/SpaceRepository.java +++ b/layer-domain/src/main/java/org/layer/domain/space/repository/SpaceRepository.java @@ -3,6 +3,8 @@ import org.layer.domain.space.entity.Space; import org.layer.domain.space.exception.SpaceException; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import java.util.List; @@ -17,5 +19,6 @@ default Space findByIdOrThrow(Long spaceId) { List findByIdIn(List ids); - + @Query("select s from Space s inner join MemberSpaceRelation ms on s.id = ms.space.id where ms.memberId = :memberId") + List findByMemberId(@Param("memberId") Long memberId); }