Skip to content

Commit

Permalink
feat: 컨트롤러와 usecase 내기록조회 result 경로 업데이트 및 토큰 방식에서 memberId 파라미터로 받아오…
Browse files Browse the repository at this point in the history
…도록 rollback
  • Loading branch information
pminsung12 committed Jul 20, 2024
1 parent e7d1e23 commit a5d1849
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import org.depromeet.spot.application.review.dto.response.BlockReviewListResponse;
import org.depromeet.spot.application.review.dto.response.MyReviewListResponse;
import org.depromeet.spot.application.review.dto.response.ReviewMonthsResponse;
import org.depromeet.spot.domain.review.MyReviewListResult;
import org.depromeet.spot.domain.review.ReviewYearMonth;
import org.depromeet.spot.domain.review.result.BlockReviewListResult;
import org.depromeet.spot.domain.review.result.MyReviewListResult;
import org.depromeet.spot.usecase.port.in.review.ReviewReadUsecase;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -65,23 +65,25 @@ public BlockReviewListResponse findReviewsByBlockId(
@ResponseStatus(HttpStatus.OK)
@GetMapping("/reviews/months")
@Operation(summary = "리뷰가 작성된 년도와 월 정보를 조회한다.")
public ReviewMonthsResponse findReviewMonths(@RequestHeader("Authorization") String token) {
public ReviewMonthsResponse findReviewMonths(
// @RequestHeader("Authorization") String token
@RequestParam @Parameter(description = "유저 ID") Long userId) {

// "Bearer " 접두사 제거
String jwt = token.replace("Bearer ", "");
// // "Bearer " 접두사 제거
// String jwt = token.replace("Bearer ", "");
//
// // ToDo: JWT 유효성 검사
// // if (!jwtTokenUtil.isValidateToken(jwt)) {
// // throw new UnauthorizedException("Invalid token");
// // }
//
// // JWT에서 id 추출
// String memberId = jwtTokenUtil.getIdFromJWT(jwt);
//
// // memberId를 Long으로 변환
// Long memberIdLong = Long.parseLong(memberId);

// ToDo: JWT 유효성 검사
// if (!jwtTokenUtil.isValidateToken(jwt)) {
// throw new UnauthorizedException("Invalid token");
// }

// JWT에서 id 추출
String memberId = jwtTokenUtil.getIdFromJWT(jwt);

// memberId를 Long으로 변환
Long memberIdLong = Long.parseLong(memberId);

List<ReviewYearMonth> yearMonths = reviewReadUsecase.findReviewMonths(memberIdLong);
List<ReviewYearMonth> yearMonths = reviewReadUsecase.findReviewMonths(userId);
return ReviewMonthsResponse.from(yearMonths);
}

Expand All @@ -91,11 +93,12 @@ public ReviewMonthsResponse findReviewMonths(@RequestHeader("Authorization") Str
summary = "자신이 작성한 리뷰 목록을 조회한다.",
description = "연도와 월로 필터링할 수 있다. 필터링 없이 전체를 조회하려면 year와 month를 null로 입력한다.")
public MyReviewListResponse findMyReviews(
@RequestParam @Parameter(description = "유저 ID") Long userId,
@ModelAttribute @Valid MyReviewRequest request,
@ParameterObject @PageableDefault(size = 20, page = 0) Pageable pageable) {
MyReviewListResult result =
reviewReadUsecase.findMyReviewsByUserId(
request.userId(),
userId,
request.year(),
request.month(),
pageable.getPageNumber(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.util.List;

import org.depromeet.spot.domain.review.MyReviewListResult;
import org.depromeet.spot.domain.review.ReviewYearMonth;
import org.depromeet.spot.domain.review.result.BlockReviewListResult;
import org.depromeet.spot.domain.review.result.MyReviewListResult;

public interface ReviewReadUsecase {
BlockReviewListResult findReviewsByStadiumIdAndBlockCode(
Expand Down

0 comments on commit a5d1849

Please sign in to comment.