-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feat: 영수증 검증 및 구독 상태 조회 API 구현 (#219)
* ✨ Feat: Subscription Entity 작성 * ✨ Feat: SubscriptionRepository 작성 * ✨ Feat: 영수증 검증 및 구독 상태 조회 API 구현 * ✨ Feat: 구독 상품 검증을 위한 설정 추가 * 🐛 Fix: 로컬에서 JWT 만료되는 버그 해결 * ♻️ Refactor: 영수증 검증 로직 리팩토링 * ✨ Feat: 구독 조회 시 상태 업데이트 로직 추가 * ✨ Feat: 스케줄링으로 구독 상태 업데이트 로직 추가 * ✨ Feat: Feign Client 방식에서 SDK 방식으로 변경 * ✨ Feat: 결제 정보 검증 로직 보완 * ✨ Feat: 사용자 인증 로직 구현 * ♻️ Refactor: 트랜잭션 범위 최소화를 위한 외부 API 호출과 DB 작업 분리 * ♻️ Refactor: 구독 상태 확인 로직을 JPA exists 쿼리로 변경 * ♻️ Refactor: 회원 구독 정보 조회 방식을 DB 조회로 최적화 * ♻️ Refactor: Subscription API 기본 경로 통합 * 🐛 Fix: ErrorCode 오타 수정
- Loading branch information
1 parent
1cbf9f1
commit bd507dc
Showing
22 changed files
with
566 additions
and
83 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
Briefing-Api/src/main/java/com/example/briefingapi/config/GoogleCredentialsConfig.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,37 @@ | ||
package com.example.briefingapi.config; | ||
|
||
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; | ||
import com.google.api.client.json.JsonFactory; | ||
import com.google.api.client.json.gson.GsonFactory; | ||
import com.google.api.services.androidpublisher.AndroidPublisher; | ||
import com.google.api.services.androidpublisher.AndroidPublisherScopes; | ||
import com.google.auth.http.HttpCredentialsAdapter; | ||
import com.google.auth.oauth2.GoogleCredentials; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.security.GeneralSecurityException; | ||
|
||
@Component | ||
public class GoogleCredentialsConfig { | ||
|
||
@Value("${subscription.google.keyfile.content}") | ||
private String googleAccountFileContent; | ||
|
||
public AndroidPublisher androidPublisher() throws IOException, GeneralSecurityException { | ||
InputStream inputStream = new ByteArrayInputStream(googleAccountFileContent.getBytes()); | ||
GoogleCredentials credentials = GoogleCredentials.fromStream(inputStream) | ||
.createScoped(AndroidPublisherScopes.ANDROIDPUBLISHER); | ||
|
||
JsonFactory jsonFactory = GsonFactory.getDefaultInstance(); | ||
|
||
return new AndroidPublisher.Builder( | ||
GoogleNetHttpTransport.newTrustedTransport(), | ||
jsonFactory, | ||
new HttpCredentialsAdapter(credentials)) | ||
.build(); | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
...ing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthMember.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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package com.example.briefingapi.security.handler.annotation; | ||
|
||
import io.swagger.v3.oas.annotations.Parameter; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.PARAMETER) | ||
@Parameter(hidden = true) | ||
public @interface AuthMember {} |
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
35 changes: 35 additions & 0 deletions
35
...g-Api/src/main/java/com/example/briefingapi/subscription/business/SubscriptionMapper.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,35 @@ | ||
package com.example.briefingapi.subscription.business; | ||
|
||
import com.example.briefingapi.subscription.presentation.dto.SubscriptionRequest; | ||
import com.example.briefingapi.subscription.presentation.dto.SubscriptionResponse; | ||
import com.example.briefingcommon.entity.Member; | ||
import com.example.briefingcommon.entity.Subscription; | ||
import com.example.briefingcommon.entity.enums.SubscriptionStatus; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class SubscriptionMapper { | ||
|
||
public static Subscription toSubscription(Member member, SubscriptionRequest.ReceiptDTO request, LocalDateTime expiryDate) { | ||
return Subscription.builder() | ||
.member(member) | ||
.type(request.getSubscriptionType()) | ||
.status(LocalDateTime.now().isBefore(expiryDate) ? SubscriptionStatus.ACTIVE : SubscriptionStatus.EXPIRED) | ||
.expiryDate(expiryDate) | ||
.build(); | ||
} | ||
|
||
public static SubscriptionResponse.SubscriptionDTO toSubscriptionDTO(Subscription subscription) { | ||
return SubscriptionResponse.SubscriptionDTO.builder() | ||
.id(subscription.getId()) | ||
.memberId(subscription.getMember().getId()) | ||
.type(subscription.getType()) | ||
.status(subscription.getStatus()) | ||
.expiryDate(subscription.getExpiryDate()) | ||
.build(); | ||
} | ||
|
||
} |
Oops, something went wrong.