Skip to content

Commit

Permalink
공유페이지 (완성/임시저장) 조회 API 리팩토링 완료 (Fastcampus-Final-Team3#182)
Browse files Browse the repository at this point in the history
* refactor : background, block, theme Setting이 null일 경우 예외처리 (Fastcampus-Final-Team3#181)

* modify : API와 통일을 위해 StyleSettingBlockStrategy를 StyleSettingStrategy으로 수정 (Fastcampus-Final-Team3#181)

* refactor : JsonNode로 파싱하는 메서드 BlockJsonProcessor로 이동 (Fastcampus-Final-Team3#181)

* refactor : FixBlockStrategy클래스에 createFixBlockDTO메소드 추가 (Fastcampus-Final-Team3#181)

* refactor : MoveBlockStrategy클래스에 createMoveBlockDTO메소드 추가 (Fastcampus-Final-Team3#181)

* refactor : 각 전략 클래스에 Response DTO 생성 메소드 구현 (Fastcampus-Final-Team3#181)

* refactor : fix block들도 CommonResponse 구현하도록 수정 (Fastcampus-Final-Team3#181)

* refactor : 공유페이지 임시저장 내역 조회시 없을 경우 null이 아닌 0L을 반환 (Fastcampus-Final-Team3#181)

* refactor : 전략 패턴 사용하여 공유페이지 조회 리팩토링 (Fastcampus-Final-Team3#181)

* refactor : 로그인 구현으로 memberId를 token에서 조회하도록 수정 (Fastcampus-Final-Team3#181)

- url 권한 허용시 다른 url과 구분을 위해 임시저장 유무 조회 entry point 수정

* modify : block_UUID에서 block_uuid로 수정 (Fastcampus-Final-Team3#181)
  • Loading branch information
miyounlee authored Oct 22, 2023
1 parent 36afeca commit ba380b6
Show file tree
Hide file tree
Showing 22 changed files with 243 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public BackgroundSettingResponse(final Long backgroundSettingBlockId, final Stri
}

public static BackgroundSettingResponse from(final BackgroundSetting backgroundSetting) {
if (backgroundSetting == null) {
return null;
}
return BackgroundSettingResponse.builder()
.backgroundSettingBlockId(backgroundSetting.getId())
.solidColor(backgroundSetting.getSolidColor())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public BlockSettingResponse(final Long blockSettingBlockId, final String shape,
}

public static BlockSettingResponse from(final BlockSetting blockSetting) {
if (blockSetting == null) {
return null;
}
return BlockSettingResponse.builder()
.blockSettingBlockId(blockSetting.getId())
.shape(blockSetting.getShape())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
import com.javajober.blocks.styleSetting.backgroundSetting.dto.response.BackgroundSettingResponse;
import com.javajober.blocks.styleSetting.blockSetting.dto.response.BlockSettingResponse;
import com.javajober.blocks.styleSetting.themeSetting.dto.response.ThemeSettingResponse;
import com.javajober.core.util.response.CommonResponse;
import lombok.Builder;
import lombok.Getter;

@Getter
public class StyleSettingResponse {
public class StyleSettingResponse implements CommonResponse {

private Long styleSettingBlockId;
private BackgroundSettingResponse backgroundSetting;
private BlockSettingResponse blockSetting;
private ThemeSettingResponse themeSetting;

public StyleSettingResponse() {

}

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public ThemeSettingResponse(final Long themeSettingBlockId, final String theme)
}

public static ThemeSettingResponse from(final ThemeSetting themeSetting) {
if (themeSetting == null) {
return null;
}
return ThemeSettingResponse.builder()
.themeSettingBlockId(themeSetting.getId())
.theme(themeSetting.getTheme())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.javajober.blocks.wallInfoBlock.dto.response;

import com.javajober.blocks.wallInfoBlock.domain.WallInfoBlock;
import com.javajober.core.util.response.CommonResponse;
import lombok.Builder;
import lombok.Getter;

@Getter
public class WallInfoBlockResponse {
public class WallInfoBlockResponse implements CommonResponse {

private Long wallInfoBlockId;
private String wallInfoTitle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.javajober.spaceWall.controller;

import com.javajober.core.message.SuccessMessage;
import com.javajober.core.security.JwtTokenizer;
import com.javajober.core.util.response.ApiResponse;
import com.javajober.core.util.ApiUtils;
import com.javajober.core.exception.ApiStatus;
Expand All @@ -26,11 +27,14 @@ public class SpaceWallController {
private final SpaceWallService spaceWallService;
private final SpaceWallFindService spaceWallFindService;
private final SpaceWallTemporaryService spaceWallTemporaryService;
private final JwtTokenizer jwtTokenizer;

public SpaceWallController(final SpaceWallService spaceWallService, final SpaceWallFindService spaceWallFindService, final SpaceWallTemporaryService spaceWallTemporaryService) {
public SpaceWallController(final SpaceWallService spaceWallService, final SpaceWallFindService spaceWallFindService,
final SpaceWallTemporaryService spaceWallTemporaryService, final JwtTokenizer jwtTokenizer) {
this.spaceWallService = spaceWallService;
this.spaceWallFindService = spaceWallFindService;
this.spaceWallTemporaryService = spaceWallTemporaryService;
this.jwtTokenizer = jwtTokenizer;
}

@PostMapping("/wall")
Expand All @@ -50,31 +54,34 @@ public ResponseEntity<ApiUtils.ApiResponse<SpaceWallSaveResponse>> savePending (
return ResponseEntity.ok(ApiUtils.success(HttpStatus.OK, SuccessMessage.SPACE_WALL_TEMPORARY_SAVE_SUCCESS, data));
}

@GetMapping("/wall-temporary/storage/{memberId}/{addSpaceId}")
@GetMapping("/wall-temporary/check/{addSpaceId}")
public ResponseEntity<ApiResponse.Response<SpaceWallTemporaryResponse>> hasSpaceWallTemporary(
@PathVariable final Long memberId, @PathVariable final Long addSpaceId) {
@PathVariable final Long addSpaceId, @RequestHeader("Authorization") String token) {

Long memberId = jwtTokenizer.getUserIdFromToken(token);
SpaceWallTemporaryResponse data = spaceWallTemporaryService.hasSpaceWallTemporary(memberId, addSpaceId);

return ApiResponse.response(ApiStatus.OK, "공유페이지 임시 저장 조회를 성공했습니다.", data);
return ApiResponse.response(ApiStatus.OK, "공유페이지 임시저장 유무 조회를 성공했습니다.", data);
}

@GetMapping("/wall/{memberId}/{addSpaceId}/{spaceWallId}")
@GetMapping("/wall/{addSpaceId}/{spaceWallId}")
public ResponseEntity<ApiResponse.Response<SpaceWallResponse>> find (
@PathVariable final Long memberId, @PathVariable final Long addSpaceId, @PathVariable final Long spaceWallId){
@PathVariable final Long addSpaceId, @PathVariable final Long spaceWallId, @RequestHeader("Authorization") String token){

Long memberId = jwtTokenizer.getUserIdFromToken(token);
SpaceWallResponse data = spaceWallFindService.find(memberId, addSpaceId, spaceWallId, FlagType.SAVED);

return ApiResponse.response(ApiStatus.OK, "공유페이지 조회를 성공했습니다.", data);
}

@GetMapping("/wall-temporary/{memberId}/{addSpaceId}/{spaceWallId}")
public ResponseEntity<ApiUtils.ApiResponse<SpaceWallResponse>> findPending(
@PathVariable final Long memberId, @PathVariable final Long addSpaceId, @PathVariable final Long spaceWallId){
@GetMapping("/wall-temporary/{addSpaceId}/{spaceWallId}")
public ResponseEntity<ApiResponse.Response<SpaceWallResponse>> findPending(
@PathVariable final Long addSpaceId, @PathVariable final Long spaceWallId, @RequestHeader("Authorization") String token){

Long memberId = jwtTokenizer.getUserIdFromToken(token);
SpaceWallResponse data = spaceWallFindService.find(memberId, addSpaceId, spaceWallId, FlagType.PENDING);

return ResponseEntity.ok(ApiUtils.success(HttpStatus.OK, SuccessMessage.SPACE_WALL_TEMPORARY_READ_SUCCESS, data));
return ApiResponse.response(ApiStatus.OK, "공유페이지 임시 저장 조회를 성공했습니다.", data);
}

@GetMapping("/wall/shareURL/{shareURL}")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/javajober/spaceWall/domain/BlockType.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum BlockType {
FREE_BLOCK("freeBlock", "자유 블록", "FreeBlockStrategy"),
LIST_BLOCK("listBlock", "리스트 블록", "ListBlockStrategy"),
SNS_BLOCK("snsBlock", "소셜 블록", "SNSBlockStrategy"),
STYLE_SETTING("styleSetting","스타일 블록","StyleSettingBlockStrategy"),
STYLE_SETTING("styleSetting","스타일 블록","StyleSettingStrategy"),
TEMPLATE_BLOCK("templateBlock", "템플릿 블록", "TemplateBlockStrategy"),
WALL_INFO_BLOCK("wallInfoBlock", "공유페이지 소개 블록", "WallInfoBlockStrategy"),
EMPTY("empty","없음","");
Expand All @@ -23,7 +23,7 @@ public enum BlockType {
private final String korTitle;
private final String strategyName;

BlockType(String engTitle, String korTitle, String strategyName) {
BlockType(final String engTitle, final String korTitle, final String strategyName) {
this.engTitle = engTitle;
this.korTitle = korTitle;
this.strategyName = strategyName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.javajober.spaceWall.dto.response;

import com.javajober.core.util.response.CommonResponse;
import com.javajober.blocks.styleSetting.dto.response.StyleSettingResponse;
import com.javajober.blocks.wallInfoBlock.dto.response.WallInfoBlockResponse;
import lombok.Builder;
import lombok.Getter;

Expand All @@ -15,16 +13,16 @@ public class SpaceWallResponse {
private Long memberId;
private Long spaceId;
private String shareURL;
private WallInfoBlockResponse wallInfoBlock;
private CommonResponse wallInfoBlock;
private List<BlockResponse<CommonResponse>> blocks;
private StyleSettingResponse styleSetting;
private CommonResponse styleSetting;

private SpaceWallResponse() {}

@Builder
public SpaceWallResponse(final String category, final Long memberId, final Long spaceId,
final String shareURL, final WallInfoBlockResponse wallInfoBlock, final List<BlockResponse<CommonResponse>> blocks,
final StyleSettingResponse styleSetting) {
public SpaceWallResponse(final String category, final Long memberId, final Long spaceId, final String shareURL, final CommonResponse wallInfoBlock,
final List<BlockResponse<CommonResponse>> blocks, final CommonResponse styleSetting) {

this.category = category;
this.memberId = memberId;
this.spaceId = spaceId;
Expand Down
Loading

0 comments on commit ba380b6

Please sign in to comment.