Skip to content

Commit

Permalink
Merge pull request #37 from depromeet/feat/LS-27
Browse files Browse the repository at this point in the history
feat/LS-27: 액션 아이템 회원 별/스페이스 별 조회, 삭제 API 구현
  • Loading branch information
clean2001 authored Jul 18, 2024
2 parents 3e57702 + 9f8a4ab commit 602490f
Show file tree
Hide file tree
Showing 17 changed files with 305 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import org.layer.domain.actionItem.dto.*;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Tag(name = "액션아이템 API")
public interface ActionItemApi {
@Operation(summary = "액션 아이템 생성", method = "POST", description = """
Expand Down Expand Up @@ -46,7 +49,8 @@ ResponseEntity<CreateActionItemResponse> createActionItem(@MemberId Long memberI
)
}
)
ResponseEntity<CreateActionItemResponse> memberActionItem(@MemberId Long memberId);
ResponseEntity<List<MemberActionItemResponse>> memberActionItem(@MemberId Long currentMemberId,
Long memberId);

@Operation(summary = "팀의 액션 아이템 조회", method = "GET", description = """
팀 아이디로 팀의 모든 액션아이템을 조회합니다.
Expand All @@ -56,14 +60,14 @@ ResponseEntity<CreateActionItemResponse> createActionItem(@MemberId Long memberI
content = {
@Content(
mediaType = "application/json",
schema = @Schema(implementation = TeamActionItemResponse.class)
schema = @Schema(implementation = SpaceActionItemElementResponse.class)
)
}
)
}
)
ResponseEntity<CreateActionItemResponse> teamActionItem(@MemberId Long memberId,
@Validated @RequestBody TeamActionItemRequest teamActionItemRequest);
ResponseEntity<SpaceActionItemResponse> teamActionItem(@MemberId Long memberId,
@PathVariable Long spaceId);

@Operation(summary = "액션 아이템 삭제", method = "DELETE", description = """
액션 아이템을 삭제합니다.
Expand All @@ -72,6 +76,5 @@ ResponseEntity<CreateActionItemResponse> teamActionItem(@MemberId Long memberId,
@ApiResponse(responseCode = "200")
}
)
ResponseEntity<CreateActionItemResponse> deleteActionItem(@MemberId Long memberId,
@Validated @RequestBody DeleteActionItemRequest deleteActionItemRequest);
}
ResponseEntity<DeleteActionItemResponse> deleteActionItem(@MemberId Long memberId, @PathVariable("actionItemId") Long actionItemId);
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package org.layer.domain.actionItem.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.dto.*;
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;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RequestMapping("/api/action-item")
@RestController
Expand All @@ -35,21 +33,29 @@ public ResponseEntity<CreateActionItemResponse> createActionItem(@MemberId Long
}

@Override
@GetMapping("/member/{memberId}")
@PreAuthorize("isAuthenticated()")
public ResponseEntity<CreateActionItemResponse> memberActionItem(@MemberId Long memberId) {
public ResponseEntity<List<MemberActionItemResponse>> memberActionItem(@MemberId Long currentMemberId, @PathVariable("memberId") Long memberId) {
List<MemberActionItemResponse> memberActionItemList = actionItemService.getMemberActionItemList(currentMemberId, memberId);

return null;
return new ResponseEntity<>(memberActionItemList, HttpStatus.OK);
}

@Override
@GetMapping("/space/{spaceId}")
@PreAuthorize("isAuthenticated()")
public ResponseEntity<CreateActionItemResponse> teamActionItem(@MemberId Long memberId, TeamActionItemRequest teamActionItemRequest) {
return null;
public ResponseEntity<SpaceActionItemResponse> teamActionItem(@MemberId Long memberId, @PathVariable("spaceId") Long spaceId) {
SpaceActionItemResponse teamActionItem = actionItemService.getSpaceActionItemList(memberId, spaceId);

return new ResponseEntity<>(teamActionItem, HttpStatus.OK);
}

@Override
@DeleteMapping("/{actionItemId}")
@PreAuthorize("isAuthenticated()")
public ResponseEntity<CreateActionItemResponse> deleteActionItem(@MemberId Long memberId, DeleteActionItemRequest deleteActionItemRequest) {
return null;
public ResponseEntity<DeleteActionItemResponse> deleteActionItem(@MemberId Long memberId, @PathVariable("actionItemId") Long actionItemId) {
DeleteActionItemResponse deleteActionItemResponse = actionItemService.deleteActionItem(memberId, actionItemId);

return new ResponseEntity<>(deleteActionItemResponse, HttpStatus.OK);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.layer.domain.actionItem.dto;

import io.swagger.v3.oas.annotations.media.Schema;

public record DeleteActionItemResponse(@Schema(description = "삭제된 액션 아이템 아이디") Long actionItemId) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import org.layer.domain.actionItem.entity.ActionItem;

@Builder
@Schema(description = "특정 회원이 작성한 액션 아이템")
Expand All @@ -27,4 +28,16 @@ public record MemberActionItemResponse (@NotNull
@NotNull
@Schema(description = "팀 스페이스의 액션 아이템인지, 개인 스페이스의 액션 아이템인지")
Boolean isTeam){

public static MemberActionItemResponse toResponse(ActionItem actionItem, String spaceName, String retrospectName, boolean isTeam) {
return MemberActionItemResponse.builder()
.actionItemId(actionItem.getId())
.actionItemContent(actionItem.getContent())
.spaceId(actionItem.getSpaceId())
.spaceName(spaceName)
.retrospectId(actionItem.getRetrospectId())
.retrospectName(retrospectName)
.isTeam(isTeam)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import org.layer.domain.actionItem.entity.ActionItem;

public record TeamActionItemRequest(
@Builder
public record SpaceActionItemElementResponse(
@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) {
}

public static SpaceActionItemElementResponse toResponse(ActionItem actionItem, String retrospectName) {
return SpaceActionItemElementResponse.builder()
.actionItemId(actionItem.getId())
.actionItemContent(actionItem.getContent())
.retrospectId(actionItem.getRetrospectId())
.retrospectName(retrospectName)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.layer.domain.actionItem.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;

import java.util.List;

@Builder
public record SpaceActionItemResponse(@NotNull
@Schema(description = "액션 아이템이 속한 스페이스 ID")
Long spaceId,
@NotNull
@Schema(description = "액션 아이템이 속한 스페이스 이름")
String spaceName,
@NotNull
@Schema(description = "스페이스의 액션아이템 리스트")
List<SpaceActionItemElementResponse> teamActionItemList
) {
}

This file was deleted.

Loading

0 comments on commit 602490f

Please sign in to comment.