-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
152 additions
and
136 deletions.
There are no files selected for viewing
18 changes: 9 additions & 9 deletions
18
layer-api/src/main/java/org/layer/domain/retrospect/controller/RetrospectApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
package org.layer.domain.retrospect.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import org.layer.common.annotation.MemberId; | ||
import org.layer.domain.retrospect.controller.dto.request.RetrospectCreateRequest; | ||
import org.layer.domain.retrospect.controller.dto.response.RetrospectCreateResponse; | ||
import org.layer.domain.retrospect.controller.dto.response.RetrospectListGetResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
|
||
@Tag(name = "회고", description = "회고 관련 API") | ||
public interface RetrospectApi { | ||
|
||
@Operation(summary = "회고 생성", description = "") | ||
ResponseEntity<Void> createRetrospect(@PathVariable("spaceId") Long spaceId, | ||
@RequestBody @Valid RetrospectCreateRequest request, @MemberId Long memberId); | ||
@Operation(summary = "회고 생성", description = "회고 생성 이후 생성된 회고의 아이디를 응답합니다.") | ||
ResponseEntity<RetrospectCreateResponse> createRetrospect(@PathVariable("spaceId") Long spaceId, | ||
@RequestBody @Valid RetrospectCreateRequest request, @MemberId Long memberId); | ||
|
||
@Operation(summary = "회고 목록 조회", description = "특정 팀 스페이스에서 작성했던 회고 목록을 보는 기능입니다.") | ||
ResponseEntity<RetrospectListGetResponse> getRetrospects(@PathVariable("spaceId") Long spaceId, @MemberId Long memberId); | ||
@Operation(summary = "회고 목록 조회", description = "특정 팀 스페이스에서 작성했던 회고 목록을 보는 기능입니다.") | ||
ResponseEntity<RetrospectListGetResponse> getRetrospects(@PathVariable("spaceId") Long spaceId, @MemberId Long memberId); | ||
} |
64 changes: 29 additions & 35 deletions
64
layer-api/src/main/java/org/layer/domain/retrospect/controller/RetrospectController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,55 @@ | ||
package org.layer.domain.retrospect.controller; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.layer.common.annotation.MemberId; | ||
import org.layer.domain.retrospect.controller.dto.request.RetrospectCreateRequest; | ||
import org.layer.domain.retrospect.controller.dto.response.RetrospectCreateResponse; | ||
import org.layer.domain.retrospect.controller.dto.response.RetrospectGetResponse; | ||
import org.layer.domain.retrospect.controller.dto.response.RetrospectListGetResponse; | ||
import org.layer.domain.retrospect.service.RetrospectService; | ||
import org.layer.domain.retrospect.service.dto.request.RetrospectCreateServiceRequest; | ||
import org.layer.domain.retrospect.service.dto.response.RetrospectListGetServiceResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
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 jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/space/{spaceId}/retrospect") | ||
public class RetrospectController implements RetrospectApi { | ||
|
||
private final RetrospectService retrospectService; | ||
private final RetrospectService retrospectService; | ||
|
||
@Override | ||
@PostMapping | ||
@PreAuthorize("isAuthenticated()") | ||
public ResponseEntity<Void> createRetrospect( | ||
@PathVariable("spaceId") Long spaceId, | ||
@RequestBody @Valid RetrospectCreateRequest request, | ||
@MemberId Long memberId) { | ||
@Override | ||
@PostMapping | ||
@PreAuthorize("isAuthenticated()") | ||
public ResponseEntity<RetrospectCreateResponse> createRetrospect( | ||
@PathVariable("spaceId") Long spaceId, | ||
@RequestBody @Valid RetrospectCreateRequest request, | ||
@MemberId Long memberId) { | ||
|
||
retrospectService.createRetrospect(request, spaceId, memberId); | ||
var newRetrospectId = retrospectService.createRetrospect(request, spaceId, memberId); | ||
|
||
return ResponseEntity.ok().build(); | ||
} | ||
return ResponseEntity.ok().body(RetrospectCreateResponse.of(newRetrospectId)); | ||
} | ||
|
||
@Override | ||
@GetMapping | ||
@PreAuthorize("isAuthenticated()") | ||
public ResponseEntity<RetrospectListGetResponse> getRetrospects(@PathVariable("spaceId") Long spaceId, | ||
@MemberId Long memberId) { | ||
@Override | ||
@GetMapping | ||
@PreAuthorize("isAuthenticated()") | ||
public ResponseEntity<RetrospectListGetResponse> getRetrospects(@PathVariable("spaceId") Long spaceId, | ||
@MemberId Long memberId) { | ||
|
||
RetrospectListGetServiceResponse serviceResponse = retrospectService.getRetrospects(spaceId, memberId); | ||
RetrospectListGetServiceResponse serviceResponse = retrospectService.getRetrospects(spaceId, memberId); | ||
|
||
List<RetrospectGetResponse> retrospectGetResponses = serviceResponse.retrospects().stream() | ||
.map(r -> RetrospectGetResponse.of(r.retrospectId(), r.title(), r.introduction(), r.isWrite(), r.retrospectStatus(), | ||
r.writeCount(), r.totalCount())) | ||
.toList(); | ||
List<RetrospectGetResponse> retrospectGetResponses = serviceResponse.retrospects().stream() | ||
.map(r -> RetrospectGetResponse.of(r.retrospectId(), r.title(), r.introduction(), r.isWrite(), r.retrospectStatus(), | ||
r.writeCount(), r.totalCount())) | ||
.toList(); | ||
|
||
return ResponseEntity.ok() | ||
.body(RetrospectListGetResponse.of(serviceResponse.layerCount(), retrospectGetResponses)); | ||
} | ||
return ResponseEntity.ok() | ||
.body(RetrospectListGetResponse.of(serviceResponse.layerCount(), retrospectGetResponses)); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...in/java/org/layer/domain/retrospect/controller/dto/response/RetrospectCreateResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.layer.domain.retrospect.controller.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(name = "RetrospectCreateResponse", description = "회고 생성 응답 DTO") | ||
public record RetrospectCreateResponse( | ||
@Schema(description = "회고 id", example = "1") | ||
Long retrospectId | ||
) { | ||
public static RetrospectCreateResponse of(Long retrospectId) { | ||
|
||
return new RetrospectCreateResponse(retrospectId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters