-
Notifications
You must be signed in to change notification settings - Fork 0
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 #134 from Next-Room/develop
[RELEASES] 구독 기능 배포
- Loading branch information
Showing
32 changed files
with
1,250 additions
and
796 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ on: | |
push: | ||
branches: | ||
- develop | ||
|
||
env: | ||
AWS_REGION: ap-northeast-2 | ||
S3_BUCKET_NAME: nextroom-dev-github-actions-s3-bucket | ||
|
@@ -21,50 +21,59 @@ jobs: | |
environment: development | ||
|
||
steps: | ||
# (1) 기본 체크아웃 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
# (1) 기본 체크아웃 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# (2) JDK 17 세팅 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
|
||
# (2) JDK 17 세팅 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
# (3) application.yml 세팅 | ||
- name: Set application.yml | ||
run: | | ||
echo "${{ secrets.NEXTROOM_APPLICATION_YML }}" > src/main/resources/application.yml | ||
# (3) application.yml 세팅 | ||
- name: set application.yml | ||
run: | | ||
echo "${{ secrets.NEXTROOM_APPLICATION_YML }}" > src/main/resources/application.yml | ||
# (3-1) Google Credential 세팅 | ||
- name: Set Google Credential | ||
id: create-json | ||
uses: jsdaniell/[email protected] | ||
with: | ||
name: "nextroom-423b5-c373d4cf16bb.json" | ||
json: ${{ secrets.NEXTROOM_GOOGLE_CREDENTIAL }} | ||
dir: 'src/main/resources/' | ||
|
||
# (4) Gradle build (Test 제외) | ||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee | ||
with: | ||
arguments: clean build -x test | ||
# (4) Gradle build (Test 제외) | ||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee | ||
with: | ||
arguments: clean build -x test | ||
|
||
# (5) AWS 인증 (IAM 사용자 Access Key, Secret Key 활용) | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.NEXTROOM_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.NEXTROOM_AWS_SECRET_ACCESS_KEY_ID }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
# (5) AWS 인증 (IAM 사용자 Access Key, Secret Key 활용) | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.NEXTROOM_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.NEXTROOM_AWS_SECRET_ACCESS_KEY_ID }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
# (6) 빌드 결과물을 S3 버킷에 업로드 | ||
- name: Upload to AWS S3 | ||
run: | | ||
aws deploy push \ | ||
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | ||
--ignore-hidden-files \ | ||
--s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \ | ||
--source . | ||
# (6) 빌드 결과물을 S3 버킷에 업로드 | ||
- name: Upload to AWS S3 | ||
run: | | ||
aws deploy push \ | ||
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | ||
--ignore-hidden-files \ | ||
--s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \ | ||
--source . | ||
# (7) S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행 | ||
- name: Deploy to AWS EC2 from S3 | ||
run: | | ||
aws deploy create-deployment \ | ||
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | ||
--deployment-config-name CodeDeployDefault.AllAtOnce \ | ||
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \ | ||
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip | ||
# (7) S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행 | ||
- name: Deploy to AWS EC2 from S3 | ||
run: | | ||
aws deploy create-deployment \ | ||
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | ||
--deployment-config-name CodeDeployDefault.AllAtOnce \ | ||
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \ | ||
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip |
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
141 changes: 70 additions & 71 deletions
141
src/main/java/com/nextroom/nextRoomServer/controller/PaymentController.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,71 +1,70 @@ | ||
//package com.nextroom.nextRoomServer.controller; | ||
// | ||
//import static com.nextroom.nextRoomServer.exceptions.StatusCode.*; | ||
// | ||
//import java.io.IOException; | ||
//import java.util.Objects; | ||
//import java.util.regex.Matcher; | ||
//import java.util.regex.Pattern; | ||
// | ||
//import org.springframework.http.ResponseEntity; | ||
//import org.springframework.web.bind.annotation.PostMapping; | ||
//import org.springframework.web.bind.annotation.RequestBody; | ||
//import org.springframework.web.bind.annotation.RequestMapping; | ||
//import org.springframework.web.bind.annotation.RestController; | ||
// | ||
//import com.fasterxml.jackson.databind.ObjectMapper; | ||
//import com.nextroom.nextRoomServer.dto.BaseResponse; | ||
//import com.nextroom.nextRoomServer.dto.SubscriptionDto; | ||
//import com.nextroom.nextRoomServer.enums.SubscriptionStatus; | ||
//import com.nextroom.nextRoomServer.service.SubscriptionService; | ||
//import com.nextroom.nextRoomServer.util.Base64Decoder; | ||
// | ||
//import io.swagger.v3.oas.annotations.tags.Tag; | ||
//import lombok.RequiredArgsConstructor; | ||
// | ||
//@Tag(name = "Payment") | ||
//@RestController | ||
//@RequestMapping("/api/v1/payment") | ||
//@RequiredArgsConstructor | ||
//public class PaymentController { | ||
// | ||
// private final SubscriptionService subscriptionService; | ||
// | ||
// @PostMapping("/purchase") | ||
// public ResponseEntity<BaseResponse> purchaseSubscription( | ||
// @RequestBody SubscriptionDto.PurchaseSubscription request | ||
// ) throws IOException { | ||
// subscriptionService.purchaseSubscription(request.getPurchaseToken(), request.getSubscriptionId()); | ||
// return ResponseEntity.ok(new BaseResponse(OK)); | ||
// } | ||
// | ||
// @PostMapping("/rtdn") | ||
// public ResponseEntity<BaseResponse> updateSubscriptionPurchase( | ||
// @RequestBody SubscriptionDto.UpdateSubscription requestBody | ||
// ) throws | ||
// Exception { | ||
// String decodedData = Base64Decoder.decode(requestBody.getMessage().getData()); | ||
// | ||
// Pattern pattern = Pattern.compile( | ||
// ".*\"subscriptionNotification\":\\{(.*?)\\}.*"); | ||
// Matcher matcher = pattern.matcher(decodedData); | ||
// | ||
// String notificationContent = matcher.group(1); | ||
// ObjectMapper objectMapper = new ObjectMapper(); | ||
// SubscriptionDto.PublishedMessage publishedMessage = objectMapper.readValue(decodedData, | ||
// SubscriptionDto.PublishedMessage.class); | ||
// System.out.println(publishedMessage.getSubscriptionNotification().getPurchaseToken()); | ||
// | ||
// // TODO handle exception | ||
// Integer notificationType = publishedMessage.getSubscriptionNotification().getNotificationType(); | ||
// String purchaseToken = publishedMessage.getSubscriptionNotification().getPurchaseToken(); | ||
// String subscriptionId = publishedMessage.getSubscriptionNotification().getSubscriptionId(); | ||
// | ||
// if (Objects.equals(notificationType, SubscriptionStatus.SUBSCRIPTION_RENEWED.getStatus())) { | ||
// subscriptionService.renew(purchaseToken, subscriptionId); | ||
// } else if (Objects.equals(notificationType, SubscriptionStatus.SUBSCRIPTION_EXPIRED.getStatus())) { | ||
// subscriptionService.expire(purchaseToken); | ||
// } | ||
// return ResponseEntity.ok(new BaseResponse(OK)); | ||
// } | ||
//} | ||
package com.nextroom.nextRoomServer.controller; | ||
|
||
import static com.nextroom.nextRoomServer.exceptions.StatusCode.*; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.nextroom.nextRoomServer.dto.BaseResponse; | ||
import com.nextroom.nextRoomServer.dto.DataResponse; | ||
import com.nextroom.nextRoomServer.dto.SubscriptionDto; | ||
import com.nextroom.nextRoomServer.service.SubscriptionService; | ||
|
||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Tag(name = "Payment") | ||
@RestController | ||
@RequestMapping("/api/v1/payment") | ||
@RequiredArgsConstructor | ||
public class PaymentController { | ||
|
||
private final SubscriptionService subscriptionService; | ||
|
||
@Operation( | ||
summary = "구독 결제", | ||
responses = { | ||
@ApiResponse(responseCode = "200", description = "OK"), | ||
@ApiResponse(responseCode = "401", description = "TOKEN_UNAUTHORIZED", content = @Content), | ||
@ApiResponse(responseCode = "403", description = "NOT_PERMITTED", content = @Content), | ||
@ApiResponse(responseCode = "404", description = "TARGET_SHOP_NOT_FOUND", content = @Content), | ||
@ApiResponse(responseCode = "500", description = "INTERNAL_SERVER_ERROR", content = @Content) | ||
} | ||
|
||
) | ||
@PostMapping("/purchase") | ||
public ResponseEntity<BaseResponse> purchaseSubscription( | ||
@RequestBody SubscriptionDto.PurchaseSubscription request | ||
) { | ||
subscriptionService.purchaseSubscription(request.getPurchaseToken()); | ||
return ResponseEntity.ok(new BaseResponse(OK)); | ||
} | ||
|
||
@Operation(hidden = true) | ||
@GetMapping | ||
public ResponseEntity<BaseResponse> getPaymentList() { | ||
return ResponseEntity.ok(new DataResponse<>(OK, subscriptionService.getShopPaymentList())); | ||
} | ||
|
||
@Operation(hidden = true) | ||
@GetMapping("/{orderId}") | ||
public ResponseEntity<BaseResponse> purchaseSubscription(@PathVariable String orderId) { | ||
return ResponseEntity.ok(new DataResponse<>(OK, subscriptionService.getPaymentDetail(orderId))); | ||
} | ||
|
||
@Operation(hidden = true) | ||
@PostMapping("/rtdn") | ||
public ResponseEntity<BaseResponse> updateSubscriptionPurchase( | ||
@RequestBody SubscriptionDto.UpdateSubscription requestBody) { | ||
subscriptionService.updateSubscription(requestBody); | ||
return ResponseEntity.ok(new BaseResponse(OK)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/nextroom/nextRoomServer/controller/ProductController.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.nextroom.nextRoomServer.controller; | ||
|
||
import static com.nextroom.nextRoomServer.exceptions.StatusCode.*; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.nextroom.nextRoomServer.dto.BaseResponse; | ||
import com.nextroom.nextRoomServer.dto.ProductDto; | ||
import com.nextroom.nextRoomServer.service.ProductService; | ||
|
||
import io.swagger.v3.oas.annotations.Hidden; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Hidden | ||
@RestController | ||
@RequestMapping("/api/v1/product") | ||
@RequiredArgsConstructor | ||
public class ProductController { | ||
private final ProductService productService; | ||
|
||
@PostMapping | ||
public ResponseEntity<BaseResponse> addProduct(@RequestBody ProductDto.AddProductRequest request) { | ||
productService.addProduct(request); | ||
return ResponseEntity.ok(new BaseResponse(OK)); | ||
} | ||
} |
Oops, something went wrong.