-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from nhnacademy-be5-T3Team/feature/point_details
feat: #89 회원 식별 로직 추가
- Loading branch information
Showing
4 changed files
with
88 additions
and
18 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/main/java/com/t3t/frontserver/pointdetail/adaptor/UserPointDetailAdaptor.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,47 @@ | ||
package com.t3t.frontserver.pointdetail.adaptor; | ||
|
||
import com.t3t.frontserver.common.exception.ApiDataFetchException; | ||
import com.t3t.frontserver.model.response.BaseResponse; | ||
import com.t3t.frontserver.pointdetail.client.UserPointDetailApiClient; | ||
import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; | ||
import feign.FeignException; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* 포인트 상세 정보를 가져오는 adaptor class | ||
* 외부 시스템으로부터 사용자의 포인트 상세 내역을 가져오는 역할 | ||
*/ | ||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class UserPointDetailAdaptor { | ||
private final UserPointDetailApiClient userPointDetailApiClient; | ||
|
||
/** | ||
* 사용자 ID와 포인트 상세 유형을 기반으로 포인트 상세 정보 조회 | ||
* @param memberId 회원 ID | ||
* @param pointDetailType 조회할 포인트 타입(사용/적립), null이면 전체 내역 조회 | ||
* @return 조건에 맞는 포인트 상세 내역 리스트를 반환. 조회된 정보가 없거나, 요청 처리 중 오류가 발생한 경우 null 반환. | ||
* @throws ApiDataFetchException 외부 시스템으로부터 데이터를 가져오는 과정에서 오류가 발생한 경우 예외 발생 | ||
* @author hydrationn(박수화) | ||
*/ | ||
public List<PointDetailResponse> getPointDetailByPointDetailType(Long memberId, String pointDetailType) { | ||
try { | ||
ResponseEntity<BaseResponse<List<PointDetailResponse>>> response = userPointDetailApiClient.getPointDetailByPointDetailType(memberId, pointDetailType); | ||
if (response.getStatusCode() == HttpStatus.OK) { | ||
return Objects.requireNonNull(response.getBody()).getData(); | ||
} | ||
return null; | ||
} catch (FeignException e) { | ||
log.error(e.getMessage()); | ||
throw new ApiDataFetchException(); | ||
} | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/t3t/frontserver/pointdetail/service/UserPointDetailService.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,30 @@ | ||
package com.t3t.frontserver.pointdetail.service; | ||
|
||
import com.t3t.frontserver.pointdetail.adaptor.UserPointDetailAdaptor; | ||
import com.t3t.frontserver.pointdetail.model.response.PointDetailResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* 사용자의 포인트 상세 정보를 관리하는 서비스 | ||
* 외부 시스템으로부터 사용자의 포인트 상세 정보를 조회하는 기능 제공 | ||
*/ | ||
@Service | ||
@RequiredArgsConstructor | ||
public class UserPointDetailService { | ||
private final UserPointDetailAdaptor userPointDetailAdaptor; | ||
|
||
/** | ||
* 회원 ID와 포인트 상세 유형을 기반으로 포인트 상세 내역 조회 | ||
* @param memberId 회원 ID | ||
* @param pointDetailType 조회할 포인트 타입(사용/적립) | ||
* @return 해당 조건에 맞는 포인트 상세 정보 리스트를 반환. | ||
* 외부 시스템으로부터 정보를 성공적으로 조회하면 그에 대한 결과를, 그렇지 않으면 null을 반환. | ||
* @author hydrationn(박수화) | ||
*/ | ||
public List<PointDetailResponse> getPointDetailByPointDetailType(Long memberId, String pointDetailType) { | ||
return userPointDetailAdaptor.getPointDetailByPointDetailType(memberId, pointDetailType); | ||
} | ||
} |