Skip to content

Commit

Permalink
✨ Feat: 테마 상세 정보 (보유여부 포함) 를 조회하는 API 구현
Browse files Browse the repository at this point in the history
테마샵에서 테마 상세 정보 조회 API

- 관련 : #427
  • Loading branch information
hosung-222 committed Jan 4, 2025
1 parent 66bca3f commit 13f4cfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.namo.spring.application.external.api.shop.controller;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.namo.spring.application.external.api.shop.dto.ThemeResponse;
import com.namo.spring.application.external.api.shop.usecase.ShoppingUseCase;
import com.namo.spring.application.external.global.common.security.authentication.SecurityUserDetails;
import com.namo.spring.core.common.response.ResponseDto;
import com.namo.spring.db.mysql.domains.shop.enums.ThemeType;

Expand All @@ -27,6 +30,7 @@ public class ShoppingController {
@GetMapping("")
@Operation(summary = "판매 중인 테마 조회", description = "판매 중인 테마 목록을 조회합니다.")
public ResponseDto<ThemeResponse.ThemeDtoList> getThemes(
@AuthenticationPrincipal SecurityUserDetails memberInfo,
@Parameter(description = "조회할 테마 타입입니다.", example = "background // profile")
@RequestParam("type") String type,
@Parameter(description = "1 부터 시작하는 페이지 번호입니다 (기본값 1)", example = "1")
Expand All @@ -43,9 +47,11 @@ public ResponseDto<ThemeResponse.ThemeDtoList> getThemes(
@GetMapping("{/themeId}")
@Operation(summary = "테마 상세 조회", description = "테마 상세 정보를 조회합니다.")
public ResponseDto<ThemeResponse.ThemeInfoDto> getThemeDetail(
@AuthenticationPrincipal SecurityUserDetails memberInfo,
@Parameter(description = "조회할 테마 ID입니다.", example = "1")
@RequestParam("themeId") Long themeId) {
@PathVariable("themeId") Long themeId) {

return ResponseDto.onSuccess(shoppingUseCase.getThemeDetail(themeId));
return ResponseDto.onSuccess(shoppingUseCase
.getThemeDetail(memberInfo.getUserId(), themeId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ public ThemeResponse.ThemeDtoList getThemesByType(ThemeType themeType, int page,
Page<Theme> themes = themeManageService.getSellingThemesByType(themeType, page, size);
return ThemeConverter.toThemeDtoList(themes);
}

@Transactional(readOnly = true)
public ThemeResponse.ThemeInfoDto getThemeDetail(Long memberId, Long themeId) {
Theme theme = themeManageService.getThemeByIdWithOwnership(memberId, themeId);
return ThemeConverter.toThemeInfoDto(theme);
}
}

0 comments on commit 13f4cfe

Please sign in to comment.