From 60fc672dd20b04f1e338e41b5ebf6da411263fc8 Mon Sep 17 00:00:00 2001 From: clean2001 Date: Sun, 14 Jul 2024 22:41:02 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20ActionItem=20Entity=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 --- .gitignore | 4 ++- .../domain/actionItem/entity/ActionItem.java | 35 +++++++++++++++++++ .../actionItem/enums/ActionItemStatus.java | 6 ++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 layer-domain/src/main/java/org/layer/domain/actionItem/entity/ActionItem.java create mode 100644 layer-domain/src/main/java/org/layer/domain/actionItem/enums/ActionItemStatus.java diff --git a/.gitignore b/.gitignore index 9dd37953..c5edf66c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,6 @@ out/ ### VS Code ### .vscode/ -*.properties \ No newline at end of file +*.properties + +layer-domain/src/main/generated \ No newline at end of file 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 new file mode 100644 index 00000000..40c20b26 --- /dev/null +++ b/layer-domain/src/main/java/org/layer/domain/actionItem/entity/ActionItem.java @@ -0,0 +1,35 @@ +package org.layer.domain.actionItem.entity; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotNull; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.layer.domain.actionItem.enums.ActionItemStatus; + +@Getter +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ActionItem { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + private Long retrospectId; // 어떤 회고에 매핑되는지 + + @NotNull + private Long spaceId; // 어떤 스페이스에 속하는지(반정규화) + + @NotNull + private Long memberId; // 작성자 + + @NotNull + private String content; // 액션 아이템 내용 + + @NotNull + private ActionItemStatus actionItemStatus; // 액션 아이템 상태 +} diff --git a/layer-domain/src/main/java/org/layer/domain/actionItem/enums/ActionItemStatus.java b/layer-domain/src/main/java/org/layer/domain/actionItem/enums/ActionItemStatus.java new file mode 100644 index 00000000..5708f54e --- /dev/null +++ b/layer-domain/src/main/java/org/layer/domain/actionItem/enums/ActionItemStatus.java @@ -0,0 +1,6 @@ +package org.layer.domain.actionItem.enums; + +public enum ActionItemStatus { + PROCESSING, + RESOLVED; // MVP 단계에선 생성, 삭제 밖에 없는 것 같지만, 확장성 고려 +} From 0628161bf03686c462cc44e793c4ec4ab8cd396f Mon Sep 17 00:00:00 2001 From: clean2001 Date: Sun, 14 Jul 2024 23:23:46 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20ActionItemApi=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/actionItem/api/ActionItemApi.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java b/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java new file mode 100644 index 00000000..10c8b7ed --- /dev/null +++ b/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java @@ -0,0 +1,33 @@ +package org.layer.domain.actionItem.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.layer.common.annotation.MemberId; +import org.layer.domain.space.dto.SpaceRequest; +import org.layer.domain.space.dto.SpaceResponse; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.ModelAttribute; + +@Tag(name = "액션아이템 API") +public interface ActionItemApi { + @Operation(summary = "액션 아이템 생성", method = "POST", description = """ + 특정 회고와 매핑되는 액션 아이템을 생성합니다. + """) + @ApiResponses({ + @ApiResponse(responseCode = "201", + content = { + @Content( + mediaType = "application/json", + schema = @Schema(implementation = SpaceResponse.SpacePage.class) + ) + } + ) + } + ) + ResponseEntity getMySpaceList(@MemberId Long memberId, @ModelAttribute @Validated SpaceRequest.GetSpaceRequest getSpaceRequest); +} From 4a5aaf229e23112812e152ee1284b956afd2041d Mon Sep 17 00:00:00 2001 From: clean2001 Date: Mon, 15 Jul 2024 16:55:55 +0900 Subject: [PATCH 3/7] =?UTF-8?q?style:=20dto=EC=97=90=20swagger=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/actionItem/api/ActionItemApi.java | 6 +-- .../controller/ActionItemController.java | 38 ++++++++++++++ .../dto/CreateActionItemRequest.java | 9 +++- .../dto/CreateActionItemResponse.java | 11 +++- .../dto/DeleteActionItemRequest.java | 7 ++- .../dto/MemberActionItemResponse.java | 30 ++++++++--- .../actionItem/dto/TeamActionItemRequest.java | 26 +++++++--- .../actionItem/service/ActionItemService.java | 50 +++++++++++++++++++ .../domain/actionItem/entity/ActionItem.java | 16 +++--- .../repository/ActionItemRepository.java | 7 +++ 10 files changed, 172 insertions(+), 28 deletions(-) create mode 100644 layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemController.java create mode 100644 layer-api/src/main/java/org/layer/domain/actionItem/service/ActionItemService.java create mode 100644 layer-domain/src/main/java/org/layer/domain/actionItem/repository/ActionItemRepository.java diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java b/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java index 311c5c4d..82fe0e42 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java @@ -29,7 +29,7 @@ public interface ActionItemApi { } ) ResponseEntity createActionItem(@MemberId Long memberId, - @ModelAttribute @Validated CreateActionItemRequest createActionItemRequest); + @Validated CreateActionItemRequest createActionItemRequest); @Operation(summary = "개인의 액션 아이템 조회", method = "GET", description = """ @@ -63,7 +63,7 @@ ResponseEntity createActionItem(@MemberId Long memberI } ) ResponseEntity teamActionItem(@MemberId Long memberId, - @ModelAttribute @Validated TeamActionItemRequest teamActionItemRequest); + @Validated TeamActionItemRequest teamActionItemRequest); @Operation(summary = "액션 아이템 삭제", method = "DELETE", description = """ 액션 아이템을 삭제합니다. @@ -73,5 +73,5 @@ ResponseEntity teamActionItem(@MemberId Long memberId, } ) ResponseEntity deleteActionItem(@MemberId Long memberId, - @ModelAttribute @Validated DeleteActionItemRequest deleteActionItemRequest); + @Validated DeleteActionItemRequest deleteActionItemRequest); } 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 new file mode 100644 index 00000000..a3006541 --- /dev/null +++ b/layer-api/src/main/java/org/layer/domain/actionItem/controller/ActionItemController.java @@ -0,0 +1,38 @@ +package org.layer.domain.actionItem.controller; + +import org.layer.common.annotation.MemberId; +import org.layer.domain.actionItem.api.ActionItemApi; +import org.layer.domain.actionItem.dto.CreateActionItemRequest; +import org.layer.domain.actionItem.dto.CreateActionItemResponse; +import org.layer.domain.actionItem.dto.DeleteActionItemRequest; +import org.layer.domain.actionItem.dto.TeamActionItemRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ActionItemController implements ActionItemApi { + @Override + @PreAuthorize("isAuthenticated()") + public ResponseEntity createActionItem(@MemberId Long memberId, CreateActionItemRequest createActionItemRequest) { + return null; + } + + @Override + @PreAuthorize("isAuthenticated()") + public ResponseEntity memberActionItem(@MemberId Long memberId) { + return null; + } + + @Override + @PreAuthorize("isAuthenticated()") + public ResponseEntity teamActionItem(@MemberId Long memberId, TeamActionItemRequest teamActionItemRequest) { + return null; + } + + @Override + @PreAuthorize("isAuthenticated()") + public ResponseEntity deleteActionItem(@MemberId Long memberId, DeleteActionItemRequest deleteActionItemRequest) { + return null; + } +} diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/dto/CreateActionItemRequest.java b/layer-api/src/main/java/org/layer/domain/actionItem/dto/CreateActionItemRequest.java index 002c1dd2..e5fbccfa 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/dto/CreateActionItemRequest.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/dto/CreateActionItemRequest.java @@ -1,6 +1,13 @@ package org.layer.domain.actionItem.dto; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; -public record CreateActionItemRequest(@NotNull Long retrospectId, @NotNull String content) { +@Schema(description = "액션 아이템 생성 요정") +public record CreateActionItemRequest(@NotNull + @Schema(description = "액션 아이템과 매핑되는 회고 ID") + Long retrospectId, + @NotNull + @Schema(description = "액션 아이템 내용") + @NotNull String content) { } diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/dto/CreateActionItemResponse.java b/layer-api/src/main/java/org/layer/domain/actionItem/dto/CreateActionItemResponse.java index 7c744682..2fe08d5f 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/dto/CreateActionItemResponse.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/dto/CreateActionItemResponse.java @@ -1,4 +1,13 @@ package org.layer.domain.actionItem.dto; -public record CreateActionItemResponse(Long memberId) { +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +@Schema(description = "액션 아이템 생성 응답") +public record CreateActionItemResponse( + @Schema(description = "액션 아이템 생성 회원 ID") + @NotNull + Long memberId, + @Schema(description = "액션 아이템과 매칭되는 회고가 진행중인 스페이스 ID") + @NotNull + Long spaceId) { } diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/dto/DeleteActionItemRequest.java b/layer-api/src/main/java/org/layer/domain/actionItem/dto/DeleteActionItemRequest.java index 3a381685..27bb72c6 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/dto/DeleteActionItemRequest.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/dto/DeleteActionItemRequest.java @@ -1,6 +1,11 @@ package org.layer.domain.actionItem.dto; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; -public record DeleteActionItemRequest(@NotNull Long actionItemId) { + +@Schema(description = "액션 아이템 삭제 요청") +public record DeleteActionItemRequest(@NotNull + @Schema(description = "액션 아이템 ID") + Long actionItemId) { } diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/dto/MemberActionItemResponse.java b/layer-api/src/main/java/org/layer/domain/actionItem/dto/MemberActionItemResponse.java index 9bb33b94..f3db4543 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/dto/MemberActionItemResponse.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/dto/MemberActionItemResponse.java @@ -1,14 +1,30 @@ package org.layer.domain.actionItem.dto; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Builder; @Builder -public record MemberActionItemResponse (@NotNull Long actionItemId, - @NotNull String actionItemContent, - @NotNull Long spaceId, - @NotNull String spaceName, - @NotNull Long retrospectId, - @NotNull String retrospectName, - @NotNull Boolean isTeam){ +@Schema(description = "특정 회원이 작성한 액션 아이템") +public record MemberActionItemResponse (@NotNull + @Schema(description = "액션아이템 ID") + Long actionItemId, + @NotNull + @Schema(description = "액션아이템 내용") + String actionItemContent, + @NotNull + @Schema(description = "액션 아이템이 속해 있는 스페이스 ID") + Long spaceId, + @NotNull + @Schema(description = "액션 아이템이 속해 있는 스페이스 이름") + String spaceName, + @NotNull + @Schema(description = "액션 아이템과 매핑되는 회고 ID") + Long retrospectId, + @NotNull + @Schema(description = "액션 아이템과 매핑되는 회고 이름") + String retrospectName, + @NotNull + @Schema(description = "팀 스페이스의 액션 아이템인지, 개인 스페이스의 액션 아이템인지") + Boolean isTeam){ } diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/dto/TeamActionItemRequest.java b/layer-api/src/main/java/org/layer/domain/actionItem/dto/TeamActionItemRequest.java index f69aecea..4b2dfcf5 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/dto/TeamActionItemRequest.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/dto/TeamActionItemRequest.java @@ -1,11 +1,25 @@ package org.layer.domain.actionItem.dto; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; -public record TeamActionItemRequest(@NotNull Long actionItemId, - @NotNull String actionItemContent, - @NotNull Long spaceId, - @NotNull String spaceName, - @NotNull Long retrospectId, - @NotNull String retrospectName) { +public record TeamActionItemRequest( + @NotNull + @Schema(description = "액션 아이템 ID") + Long actionItemId, + @NotNull + @Schema(description = "액션 아이템과 내용") + String actionItemContent, + @NotNull + @Schema(description = "액션 아이템이 속한 스페이스 ID") + Long spaceId, + @NotNull + @Schema(description = "액션 아이템이 속한 스페이스 이름") + String spaceName, + @NotNull + @Schema(description = "액션 아이템과 매핑되는 회고 ID") + Long retrospectId, + @NotNull + @Schema(description = "액션 아이템과 매핑되는 회고 이름") + String retrospectName) { } 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 new file mode 100644 index 00000000..6f779544 --- /dev/null +++ b/layer-api/src/main/java/org/layer/domain/actionItem/service/ActionItemService.java @@ -0,0 +1,50 @@ +package org.layer.domain.actionItem.service; + +import lombok.RequiredArgsConstructor; +import org.layer.domain.actionItem.dto.CreateActionItemResponse; +import org.layer.domain.actionItem.entity.ActionItem; +import org.layer.domain.actionItem.repository.ActionItemRepository; +import org.layer.domain.retrospect.entity.Retrospect; +import org.layer.domain.retrospect.repository.RetrospectRepository; +import org.layer.domain.space.entity.MemberSpaceRelation; +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 java.util.Optional; + +import static org.layer.common.exception.MemberSpaceRelationExceptionType.NOT_FOUND_MEMBER_SPACE_RELATION; +import static org.layer.domain.actionItem.enums.ActionItemStatus.PROCESSING; + +@RequiredArgsConstructor +@Service +public class ActionItemService { + private final ActionItemRepository actionItemRepository; + private final SpaceRepository spaceRepository; + private final RetrospectRepository retrospectRepository; + private final MemberSpaceRelationRepository memberSpaceRelationRepository; + public CreateActionItemResponse createActionItem(Long memberId, Long retrospectId, String content) { + + // 멤버가 해당 회고가 진행 중인 스페이스에 속하는지 확인 + Retrospect retrospect = retrospectRepository.findByIdOrThrow(retrospectId); + Optional team = memberSpaceRelationRepository.findBySpaceIdAndMemberId(retrospect.getSpaceId(), retrospectId); + + if(team.isEmpty()) { + throw new MemberSpaceRelationException(NOT_FOUND_MEMBER_SPACE_RELATION); + } + + // 액션 아이템 생성 + actionItemRepository.save(ActionItem.builder() + .retrospectId(retrospectId) + .spaceId(retrospect.getSpaceId()) + .memberId(memberId) + .content(content) + .actionItemStatus(PROCESSING) + .build()); + + // + return new CreateActionItemResponse(memberId, retrospect.getSpaceId()); + } + +} 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 40c20b26..b1feae9f 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 @@ -1,18 +1,15 @@ package org.layer.domain.actionItem.entity; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; import org.layer.domain.actionItem.enums.ActionItemStatus; +@Builder @Getter -@Entity +@AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity public class ActionItem { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -31,5 +28,6 @@ public class ActionItem { private String content; // 액션 아이템 내용 @NotNull + @Enumerated(EnumType.STRING) private ActionItemStatus actionItemStatus; // 액션 아이템 상태 -} +} \ No newline at end of file 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 new file mode 100644 index 00000000..6b0b1eb1 --- /dev/null +++ b/layer-domain/src/main/java/org/layer/domain/actionItem/repository/ActionItemRepository.java @@ -0,0 +1,7 @@ +package org.layer.domain.actionItem.repository; + +import org.layer.domain.actionItem.entity.ActionItem; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ActionItemRepository extends JpaRepository { +} From d8e682a3fe51e3e74ca8e1f423b94ebf0994aa3c Mon Sep 17 00:00:00 2001 From: clean2001 Date: Mon, 15 Jul 2024 18:23:56 +0900 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20=EC=95=A1=EC=85=98=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=ED=85=9C=20=EC=83=9D=EC=84=B1=20API=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/actionItem/api/ActionItemApi.java | 8 ++++---- .../controller/ActionItemController.java | 20 +++++++++++++++++-- .../actionItem/service/ActionItemService.java | 1 - 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java b/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java index 82fe0e42..e4856861 100644 --- a/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java +++ b/layer-api/src/main/java/org/layer/domain/actionItem/api/ActionItemApi.java @@ -10,7 +10,7 @@ import org.layer.domain.actionItem.dto.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestBody; @Tag(name = "액션아이템 API") public interface ActionItemApi { @@ -29,7 +29,7 @@ public interface ActionItemApi { } ) ResponseEntity createActionItem(@MemberId Long memberId, - @Validated CreateActionItemRequest createActionItemRequest); + @Validated @RequestBody CreateActionItemRequest createActionItemRequest); @Operation(summary = "개인의 액션 아이템 조회", method = "GET", description = """ @@ -63,7 +63,7 @@ ResponseEntity createActionItem(@MemberId Long memberI } ) ResponseEntity teamActionItem(@MemberId Long memberId, - @Validated TeamActionItemRequest teamActionItemRequest); + @Validated @RequestBody TeamActionItemRequest teamActionItemRequest); @Operation(summary = "액션 아이템 삭제", method = "DELETE", description = """ 액션 아이템을 삭제합니다. @@ -73,5 +73,5 @@ ResponseEntity teamActionItem(@MemberId Long memberId, } ) ResponseEntity deleteActionItem(@MemberId Long memberId, - @Validated DeleteActionItemRequest deleteActionItemRequest); + @Validated @RequestBody DeleteActionItemRequest deleteActionItemRequest); } 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 a3006541..e03ebe39 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 @@ -1,21 +1,37 @@ package org.layer.domain.actionItem.controller; +import lombok.RequiredArgsConstructor; import org.layer.common.annotation.MemberId; import org.layer.domain.actionItem.api.ActionItemApi; import org.layer.domain.actionItem.dto.CreateActionItemRequest; import org.layer.domain.actionItem.dto.CreateActionItemResponse; import org.layer.domain.actionItem.dto.DeleteActionItemRequest; import org.layer.domain.actionItem.dto.TeamActionItemRequest; +import org.layer.domain.actionItem.service.ActionItemService; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@RequiredArgsConstructor +@RequestMapping("/api/action-item") @RestController public class ActionItemController implements ActionItemApi { + private final ActionItemService actionItemService; @Override + @PostMapping("/create") @PreAuthorize("isAuthenticated()") - public ResponseEntity createActionItem(@MemberId Long memberId, CreateActionItemRequest createActionItemRequest) { - return null; + public ResponseEntity createActionItem(@MemberId Long memberId, + @Validated @RequestBody CreateActionItemRequest createActionItemRequest) { + CreateActionItemResponse actionItem = actionItemService.createActionItem(memberId, + createActionItemRequest.retrospectId(), + createActionItemRequest.content()); + + return new ResponseEntity<>(actionItem, HttpStatus.CREATED); } @Override 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 6f779544..1767ba4d 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 @@ -43,7 +43,6 @@ public CreateActionItemResponse createActionItem(Long memberId, Long retrospectI .actionItemStatus(PROCESSING) .build()); - // return new CreateActionItemResponse(memberId, retrospect.getSpaceId()); } From 59e00e1292c307c73b272f6b19af770a04a6ce05 Mon Sep 17 00:00:00 2001 From: clean2001 Date: Mon, 15 Jul 2024 18:43:07 +0900 Subject: [PATCH 5/7] =?UTF-8?q?chore:=20ActionItem=20BaseEntity=20?= =?UTF-8?q?=EC=83=81=EC=86=8D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActionItemController.java | 1 + .../actionItem/service/ActionItemService.java | 5 +++-- .../domain/actionItem/entity/ActionItem.java | 15 ++++++++++++--- .../repository/ActionItemRepository.java | 1 + 4 files changed, 17 insertions(+), 5 deletions(-) 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 e03ebe39..83c8fc5e 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 @@ -37,6 +37,7 @@ public ResponseEntity createActionItem(@MemberId Long @Override @PreAuthorize("isAuthenticated()") public ResponseEntity memberActionItem(@MemberId Long memberId) { + return null; } 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 1767ba4d..4e08f87c 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 @@ -9,7 +9,6 @@ import org.layer.domain.space.entity.MemberSpaceRelation; 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 java.util.Optional; @@ -21,7 +20,6 @@ @Service public class ActionItemService { private final ActionItemRepository actionItemRepository; - private final SpaceRepository spaceRepository; private final RetrospectRepository retrospectRepository; private final MemberSpaceRelationRepository memberSpaceRelationRepository; public CreateActionItemResponse createActionItem(Long memberId, Long retrospectId, String content) { @@ -46,4 +44,7 @@ public CreateActionItemResponse createActionItem(Long memberId, Long retrospectI return new CreateActionItemResponse(memberId, retrospect.getSpaceId()); } + + + } 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 b1feae9f..e7e9a1e7 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 @@ -3,14 +3,15 @@ import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.*; +import lombok.experimental.SuperBuilder; +import org.layer.domain.BaseEntity; import org.layer.domain.actionItem.enums.ActionItemStatus; -@Builder @Getter -@AllArgsConstructor +@SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity -public class ActionItem { +public class ActionItem extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -30,4 +31,12 @@ public class ActionItem { @NotNull @Enumerated(EnumType.STRING) private ActionItemStatus actionItemStatus; // 액션 아이템 상태 + + public ActionItem(Long retrospectId, Long spaceId, Long memberId, String content, ActionItemStatus actionItemStatus) { + this.retrospectId = retrospectId; + this.spaceId = spaceId; + this.memberId = memberId; + this.content = content; + this.actionItemStatus = actionItemStatus; + } } \ No newline at end of file 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 6b0b1eb1..2a666cca 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 @@ -4,4 +4,5 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface ActionItemRepository extends JpaRepository { +// List findAllByMemberIdAndActionItemStatusOrderByCreatedTimeDesc(Long memberId, ActionItemStatus actionItemStatus); } From 4ff7402de14b92f1258a028c1f5500a6deee42c2 Mon Sep 17 00:00:00 2001 From: clean2001 Date: Mon, 15 Jul 2024 18:44:33 +0900 Subject: [PATCH 6/7] =?UTF-8?q?style:=20=EC=A3=BC=EC=84=9D=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layer/domain/actionItem/repository/ActionItemRepository.java | 1 - 1 file changed, 1 deletion(-) 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 2a666cca..6b0b1eb1 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 @@ -4,5 +4,4 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface ActionItemRepository extends JpaRepository { -// List findAllByMemberIdAndActionItemStatusOrderByCreatedTimeDesc(Long memberId, ActionItemStatus actionItemStatus); } From 3b23cafa7d1eb3114fddf626508c48d3b7e75e40 Mon Sep 17 00:00:00 2001 From: clean2001 Date: Mon, 15 Jul 2024 18:53:25 +0900 Subject: [PATCH 7/7] =?UTF-8?q?style:=20=EC=A4=84=EB=B0=94=EA=BF=88=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 --- .../org/layer/domain/actionItem/service/ActionItemService.java | 1 + 1 file changed, 1 insertion(+) 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 4e08f87c..65bd9b09 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 @@ -22,6 +22,7 @@ public class ActionItemService { private final ActionItemRepository actionItemRepository; private final RetrospectRepository retrospectRepository; private final MemberSpaceRelationRepository memberSpaceRelationRepository; + public CreateActionItemResponse createActionItem(Long memberId, Long retrospectId, String content) { // 멤버가 해당 회고가 진행 중인 스페이스에 속하는지 확인