Skip to content

Commit

Permalink
Merge pull request #134 from Next-Room/develop
Browse files Browse the repository at this point in the history
[RELEASES] 구독 기능 배포
  • Loading branch information
eunsol-an authored Sep 7, 2024
2 parents 1bf81a5 + 7adbccc commit 5ba5322
Show file tree
Hide file tree
Showing 32 changed files with 1,250 additions and 796 deletions.
93 changes: 51 additions & 42 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- develop

env:
AWS_REGION: ap-northeast-2
S3_BUCKET_NAME: nextroom-dev-github-actions-s3-bucket
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ public ResponseEntity<BaseResponse> reissue(@RequestBody AuthDto.ReissueRequestD
return ResponseEntity.ok(new DataResponse<>(OK, authService.reissue(request)));
}


@PostMapping("/rtdntest")
public void reissue(@RequestBody Object message) {
System.out.println(message);

}

@Operation(
summary = "회원탈퇴",
responses = {
Expand Down
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));
}
}
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));
}
}
Loading

0 comments on commit 5ba5322

Please sign in to comment.