Skip to content

Commit

Permalink
[api-server-v1] feat: 하위 페이지 생성시 블록처럼 보이도록 응답 객체 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
gdtknight committed Oct 5, 2023
1 parent 78d7158 commit a74fbeb
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package kr.joberchip.server.v1.page.controller;

import java.util.Objects;
import java.util.UUID;
import javax.validation.Valid;
import kr.joberchip.core.page.types.PrivilegeType;
import kr.joberchip.server.v1._config.security.CustomUserDetails;
import kr.joberchip.server.v1._errors.ErrorMessage;
import kr.joberchip.server.v1._errors.exceptions.ApiClientException;
import kr.joberchip.server.v1._utils.ApiResponse;
import kr.joberchip.server.v1.block.controller.dto.BlockResponseDTO;
import kr.joberchip.server.v1.page.controller.dto.*;
import kr.joberchip.server.v1.page.repository.SharePageRepository;
import kr.joberchip.server.v1.page.service.SharePagePrivilegeService;
import kr.joberchip.server.v1.page.service.SharePageService;
import lombok.RequiredArgsConstructor;
Expand All @@ -21,6 +24,7 @@
@RequestMapping("/v1/page")
@RequiredArgsConstructor
public class SharePageController {
private final SharePageRepository sharePageRepository;
private final SharePageService sharePageService;
private final SharePagePrivilegeService sharePagePrivilegeService;

Expand Down Expand Up @@ -88,7 +92,7 @@ public ApiResponse.Result<SharePageTreeResponseDTO.PageTreeNode> pageBreadCrumbB
* @return 생성된 페이지 정보
*/
@PostMapping("/new")
public ApiResponse.Result<Object> createSharePage(
public ApiResponse.Result<BlockResponseDTO> createSharePage(
@AuthenticationPrincipal CustomUserDetails loginUser,
@RequestBody @Valid SharePageRequestDTO createSharePageRequestDTO,
Errors errors) {
Expand All @@ -106,7 +110,12 @@ public ApiResponse.Result<Object> createSharePage(
sharePagePrivilegeService.registerPrivilege(
loginUser.user().getUserId(), generatedPageId, PrivilegeType.EDIT);

return ApiResponse.success();
BlockResponseDTO response =
BlockResponseDTO.fromEntity(
Objects.requireNonNull(
sharePageRepository.findSharePageByObjectId(generatedPageId).orElse(null)));

return ApiResponse.success(response);
}

@PutMapping("/{pageId}")
Expand Down

0 comments on commit a74fbeb

Please sign in to comment.