diff --git a/.github/workflows/ci_gradle.yml b/.github/workflows/ci_gradle.yml index dda82537..1b3ac95e 100644 --- a/.github/workflows/ci_gradle.yml +++ b/.github/workflows/ci_gradle.yml @@ -24,8 +24,8 @@ jobs: echo "spring:" > application.yml echo " profiles:" >> application.yml echo " group:" >> application.yml - echo " "local": "db, s3, secret"" >> application.yml - echo " "prod": "db, s3, redis"" >> application.yml + echo " "local": "db, s3, email, portone, secret"" >> application.yml + echo " "prod": "db, s3, redis, email, portone"" >> application.yml echo " default: prod" >> application.yml echo " servlet:" >> application.yml @@ -49,13 +49,8 @@ jobs: spring.jwt.secret: ${{ secrets.JWT_SECRET }} spring.jwt.token.access-expiration-time: ${{ secrets.JWT_ACCESS_EXPIRATION_TIME }} spring.jwt.token.refresh-expiration-time: ${{ secrets.JWT_REFRESH_EXPIRATION_TIME }} - mail.smtp.port: ${{ secrets.EMAIL_PORT }} - AdminMail.id: ${{ secrets.EMAIL_ID }} - AdminMail.password: ${{ secrets.EMAIL_PASSWORD }} firebase.fcmUrl: ${{ secrets.FIREBASE_URL}} firebase.firebaseConfigPath: ${{ secrets.FIREBASE_PATH}} - PORT_ONE_KEY: ${{ secrets.PORT_ONE_KEY}} - PORT_ONE_SECRET: ${{ secrets.PORT_ONE_SECRET}} - name: 4) Set application-db.yml uses: microsoft/variable-substitution@v1 @@ -84,6 +79,23 @@ jobs: spring.data.redis.host: ${{ secrets.REDIS_HOST }} spring.data.redis.port: ${{ secrets.REDIS_PORT }} + - name: 7) Set application-email.yml + uses: microsoft/variable-substitution@v1 + with: + files: ./core/core-infra-email/src/main/resources/application-email.yml + env: + mail.smtp.port: ${{ secrets.EMAIL_PORT }} + AdminMail.id: ${{ secrets.EMAIL_ID }} + AdminMail.password: ${{ secrets.EMAIL_PASSWORD }} + + - name: 8) Set application-portone.yml + uses: microsoft/variable-substitution@v1 + with: + files: ./core/core-infra-portone/src/main/resources/application-portone.yml + env: + PORT_ONE_KEY: ${{ secrets.PORT_ONE_KEY}} + PORT_ONE_SECRET: ${{ secrets.PORT_ONE_SECRET}} + - name: Grant execute permission for gradlew and build run: | chmod +x ./gradlew diff --git a/api/build.gradle b/api/build.gradle index 73f1a778..5129809c 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -4,6 +4,8 @@ dependencies { implementation project(':core:core-infra-db'); implementation project(':core:core-infra-s3'); implementation project(':core:core-infra-redis'); + implementation project(':core:core-infra-email'); + implementation project(':core:core-infra-portone'); // Core implementation 'org.springframework.boot:spring-boot-starter-data-jpa' @@ -15,9 +17,9 @@ dependencies { implementation 'org.slf4j:slf4j-api:2.0.7' // Lombok - implementation 'org.projectlombok:lombok:1.18.22' - annotationProcessor('org.projectlombok:lombok') - testAnnotationProcessor('org.projectlombok:lombok') +// implementation 'org.projectlombok:lombok:1.18.22' +// annotationProcessor('org.projectlombok:lombok') +// testAnnotationProcessor('org.projectlombok:lombok') // Jwt implementation 'io.jsonwebtoken:jjwt-api:0.12.3' @@ -31,16 +33,9 @@ dependencies { // Validation implementation 'org.springframework.boot:spring-boot-starter-validation' - // email - implementation 'org.springframework.boot:spring-boot-starter-mail' - // FCM implementation 'com.google.firebase:firebase-admin:9.1.1' implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2' - - // Iamport - implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' - implementation 'com.github.iamport:iamport-rest-client-java:0.2.23' } bootJar { enabled = true } jar { enabled = false } diff --git a/api/out/production/resources/application-local.yml b/api/out/production/resources/application-local.yml deleted file mode 100644 index fc0720fc..00000000 --- a/api/out/production/resources/application-local.yml +++ /dev/null @@ -1,14 +0,0 @@ -server: - port: 8080 - -spring: - jwt: - secret: EENY5W0eegTf1naQB2eDeyCLl5kRS2b8xa5c4qLdS0hmVjtbvo8tOyhPMcAmtPuQ - token: - access-expiration-time: 999999999 - refresh-expiration-time: 999999999 - - data: - redis: - host: localhost - port: 6379 diff --git a/api/out/production/resources/application-prod.yml b/api/out/production/resources/application-prod.yml deleted file mode 100644 index 8dcd5ffd..00000000 --- a/api/out/production/resources/application-prod.yml +++ /dev/null @@ -1,37 +0,0 @@ -server: - port: 8080 - -spring: - jwt: - secret: ${JWT_SECRET} - token: - access-expiration-time: ${JWT_ACCESS_EXPIRATION_TIME} - refresh-expiration-time: ${JWT_REFRESH_EXPIRATION_TIME} - - data: - redis: - host: ${REDIS_HOST} - port: ${REDIS_PORT} - -mail: - smtp: - port: ${EMAIL_PORT} - auth: true - starttls: - required: true - enable: true - socketFactory: - class: javax.net.ssl.SSLSocketFactory - fallback: false - -AdminMail: - id: ${EMAIL_ID} - password: ${EMAIL_PASSWORD} - -firebase: - fcmUrl: ${FIREBASE_URL} - firebaseConfigPath: ${FIREBASE_PATH} - scope: https://www.googleapis.com/auth/cloud-platform - -PORT_ONE_KEY: ${PORT_ONE_KEY} -PORT_ONE_SECRET: ${PORT_ONE_SECRET} diff --git a/api/out/production/resources/application.yml b/api/out/production/resources/application.yml deleted file mode 100644 index 0a6b6276..00000000 --- a/api/out/production/resources/application.yml +++ /dev/null @@ -1,14 +0,0 @@ -server: - port: 8080 - -spring: - profiles: - group: - "local": "db, s3, secret" - "prod": "db, s3" - default: local - - servlet: - multipart: - max-file-size: 20MB - max-request-size: 20MB diff --git a/api/src/main/java/com/sponus/sponusbe/domain/organization/service/OrganizationService.java b/api/src/main/java/com/sponus/sponusbe/domain/organization/service/OrganizationService.java index 69466215..0c44cf49 100644 --- a/api/src/main/java/com/sponus/sponusbe/domain/organization/service/OrganizationService.java +++ b/api/src/main/java/com/sponus/sponusbe/domain/organization/service/OrganizationService.java @@ -3,9 +3,7 @@ import static com.sponus.sponusbe.domain.organization.exception.OrganizationErrorCode.*; import java.util.List; -import java.util.Random; -import org.springframework.mail.javamail.JavaMailSender; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -15,6 +13,7 @@ import com.sponus.coredomain.domain.notification.repository.NotificationRepository; import com.sponus.coredomain.domain.organization.Organization; import com.sponus.coredomain.domain.organization.repository.OrganizationRepository; +import com.sponus.coreinfraemail.EmailUtil; import com.sponus.coreinfras3.S3Util; import com.sponus.sponusbe.domain.notification.exception.NotificationErrorCode; import com.sponus.sponusbe.domain.notification.exception.NotificationException; @@ -24,8 +23,6 @@ import com.sponus.sponusbe.domain.organization.dto.OrganizationUpdateRequest; import com.sponus.sponusbe.domain.organization.exception.OrganizationException; -import jakarta.mail.internet.InternetAddress; -import jakarta.mail.internet.MimeMessage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -38,8 +35,8 @@ public class OrganizationService { private final OrganizationRepository organizationRepository; private final NotificationRepository notificationRepository; private final PasswordEncoder passwordEncoder; - private final JavaMailSender emailSender; private final S3Util s3Util; + private final EmailUtil emailUtil; public OrganizationJoinResponse join(OrganizationJoinRequest request) { final Organization organization = organizationRepository.save( @@ -72,57 +69,7 @@ public void deactivateOrganization(Long organizationId) { } public String sendEmail(String to) throws Exception { - String code = createEmailCode(); - MimeMessage message = createEmail(to, code); - emailSender.send(message); - return code; - } - - private MimeMessage createEmail(String to, String code) throws Exception { - log.info("보내는 대상 : " + to); - log.info("인증 코드 : " + code); - MimeMessage message = emailSender.createMimeMessage(); - message.addRecipients(MimeMessage.RecipientType.TO, to); // 보내는 대상 - message.setSubject("Spon-us 인증 코드 발급입니다."); // 제목 - - String msgg = ""; - msgg += "
"; - msgg += "

Spon-us 인증 코드입니다.

"; // 동적으로 메시지 내용 변경 - msgg += "
"; - msgg += "
"; - msgg += "

인증 코드

"; - msgg += "
"; - msgg += "인증 코드 : "; - msgg += code + "

"; - msgg += "
"; - message.setText(msgg, "utf-8", "html"); // 내용 - message.setFrom(new InternetAddress("Spon-us_team", "Spon-us")); // 보내는 사람 - - return message; - } - - public static String createEmailCode() { - StringBuilder code = new StringBuilder(); - Random rnd = new Random(); - - for (int i = 0; i < 6; i++) { // 인증 코드 6자리 - int index = rnd.nextInt(3); // 0~2 까지 랜덤 - switch (index) { - case 0: - code.append((char)((rnd.nextInt(26)) + 97)); - // a~z (ex. 1+97=98 => (char)98 = 'b') - break; - case 1: - code.append((char)((rnd.nextInt(26)) + 65)); - // A~Z - break; - default: - code.append((rnd.nextInt(10))); - // 0~9 - break; - } - } - return code.toString(); + return emailUtil.sendEmail(to); } public List searchOrganization(String keyword) { diff --git a/api/src/main/java/com/sponus/sponusbe/domain/payment/controller/PaymentController.java b/api/src/main/java/com/sponus/sponusbe/domain/payment/controller/PaymentController.java deleted file mode 100644 index bf7b017a..00000000 --- a/api/src/main/java/com/sponus/sponusbe/domain/payment/controller/PaymentController.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.sponus.sponusbe.domain.payment.controller; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import com.siot.IamportRestClient.response.Payment; -import com.sponus.coredomain.domain.common.ApiResponse; -import com.sponus.coredomain.domain.organization.Organization; -import com.sponus.sponusbe.auth.annotation.AuthOrganization; -import com.sponus.sponusbe.domain.payment.dto.PaymentRequest; -import com.sponus.sponusbe.domain.payment.service.PaymentService; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@RestController -@RequiredArgsConstructor -public class PaymentController { - - private final PaymentService paymentService; - - @PostMapping("/api/v1/payments") - public ApiResponse paymentByImpUid( - @AuthOrganization Organization authOrganization, - @RequestBody PaymentRequest request) { - return ApiResponse.onSuccess(paymentService.paymentByImpUid(request, authOrganization)); - } -} diff --git a/api/src/main/java/com/sponus/sponusbe/domain/payment/controller/PaymentViewController.java b/api/src/main/java/com/sponus/sponusbe/domain/payment/controller/PaymentViewController.java deleted file mode 100644 index a1364911..00000000 --- a/api/src/main/java/com/sponus/sponusbe/domain/payment/controller/PaymentViewController.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.sponus.sponusbe.domain.payment.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -@Controller -public class PaymentViewController { - @GetMapping("/payment") - public String payment() { - return "payment"; - } -} diff --git a/api/src/main/java/com/sponus/sponusbe/domain/propose/exception/ProposeErrorCode.java b/api/src/main/java/com/sponus/sponusbe/domain/propose/exception/ProposeErrorCode.java index 608001d1..50aa9b25 100644 --- a/api/src/main/java/com/sponus/sponusbe/domain/propose/exception/ProposeErrorCode.java +++ b/api/src/main/java/com/sponus/sponusbe/domain/propose/exception/ProposeErrorCode.java @@ -17,9 +17,7 @@ public enum ProposeErrorCode implements BaseErrorCode { INVALID_PROPOSED_ORGANIZATION(HttpStatus.BAD_REQUEST, "PROP4003", "제안을 받은 단체만 접근이 가능합니다."), PROPOSE_STATUS_NOT_PENDING(HttpStatus.BAD_REQUEST, "PROP4004", "수락 대기 중인 제안만 수정이 가능합니다."), INVALID_PROPOSE_STATUS(HttpStatus.BAD_REQUEST, "PROP4005", "유효하지 않은 제안 상태입니다."), - PROPOSE_ALREADY_PAID(HttpStatus.BAD_REQUEST, "PROP4006", "이미 결제된 제안입니다."), - PROPOSE_NOT_FOUND(HttpStatus.NOT_FOUND, "PROP4040", "해당 제안이 존재하지 않습니다."), - PAYMENT_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "PROP5001", "결제 중 에러가 발생했습니다."); + PROPOSE_NOT_FOUND(HttpStatus.NOT_FOUND, "PROP4040", "해당 제안이 존재하지 않습니다."); private final HttpStatus httpStatus; private final String code; diff --git a/api/src/main/resources/application-prod.yml b/api/src/main/resources/application-prod.yml index a0da6eef..767a31df 100644 --- a/api/src/main/resources/application-prod.yml +++ b/api/src/main/resources/application-prod.yml @@ -8,25 +8,7 @@ spring: access-expiration-time: ${JWT_ACCESS_EXPIRATION_TIME} refresh-expiration-time: ${JWT_REFRESH_EXPIRATION_TIME} -mail: - smtp: - port: ${EMAIL_PORT} - auth: true - starttls: - required: true - enable: true - socketFactory: - class: javax.net.ssl.SSLSocketFactory - fallback: false - -AdminMail: - id: ${EMAIL_ID} - password: ${EMAIL_PASSWORD} - firebase: fcmUrl: ${FIREBASE_URL} firebaseConfigPath: ${FIREBASE_PATH} scope: https://www.googleapis.com/auth/cloud-platform - -PORT_ONE_KEY: ${PORT_ONE_KEY} -PORT_ONE_SECRET: ${PORT_ONE_SECRET} diff --git a/api/src/main/resources/application.yml b/api/src/main/resources/application.yml index 91850ab6..3c8d8a08 100644 --- a/api/src/main/resources/application.yml +++ b/api/src/main/resources/application.yml @@ -4,8 +4,8 @@ server: spring: profiles: group: - "local": "db, s3, secret" - "prod": "db, s3, redis" + "local": "db, s3, email, portone, secret" + "prod": "db, s3, redis, email, portone" default: local servlet: diff --git a/api/src/main/resources/templates/payment.html b/api/src/main/resources/templates/payment.html deleted file mode 100644 index 23407b7b..00000000 --- a/api/src/main/resources/templates/payment.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - Sample Payment - - - - - diff --git a/core/core-infra-email/build.gradle b/core/core-infra-email/build.gradle new file mode 100644 index 00000000..a87592dd --- /dev/null +++ b/core/core-infra-email/build.gradle @@ -0,0 +1,7 @@ +dependencies { + // email + implementation 'org.springframework.boot:spring-boot-starter-mail' +} + +bootJar { enabled = false } +jar { enabled = true } diff --git a/api/src/main/java/com/sponus/sponusbe/global/config/EmailConfig.java b/core/core-infra-email/src/main/java/com/sponus/coreinfraemail/EmailConfig.java similarity index 81% rename from api/src/main/java/com/sponus/sponusbe/global/config/EmailConfig.java rename to core/core-infra-email/src/main/java/com/sponus/coreinfraemail/EmailConfig.java index 1be3e0b1..a00a329a 100644 --- a/api/src/main/java/com/sponus/sponusbe/global/config/EmailConfig.java +++ b/core/core-infra-email/src/main/java/com/sponus/coreinfraemail/EmailConfig.java @@ -1,4 +1,4 @@ -package com.sponus.sponusbe.global.config; +package com.sponus.coreinfraemail; import java.util.Properties; @@ -13,14 +13,15 @@ public class EmailConfig { @Value("${mail.smtp.port}") private int port; - @Value("${mail.smtp.port}") - private int socketPort; @Value("${mail.smtp.auth}") private boolean auth; @Value("${mail.smtp.starttls.enable}") private boolean starttls; @Value("${mail.smtp.starttls.required}") - private boolean startlls_required; + private boolean startllsRequired; + + @Value("${mail.smtp.socketFactory.class}") + private String socketFactory; @Value("${mail.smtp.socketFactory.fallback}") private boolean fallback; @Value("${AdminMail.id}") @@ -42,12 +43,12 @@ public JavaMailSender javaMailService() { private Properties getMailProperties() { Properties pt = new Properties(); - pt.put("mail.smtp.socketFactory.port", socketPort); + pt.put("mail.smtp.socketFactory.port", port); pt.put("mail.smtp.auth", auth); pt.put("mail.smtp.starttls.enable", starttls); - pt.put("mail.smtp.starttls.required", startlls_required); + pt.put("mail.smtp.starttls.required", startllsRequired); pt.put("mail.smtp.socketFactory.fallback", fallback); - pt.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); + pt.put("mail.smtp.socketFactory.class", socketFactory); return pt; } } diff --git a/core/core-infra-email/src/main/java/com/sponus/coreinfraemail/EmailUtil.java b/core/core-infra-email/src/main/java/com/sponus/coreinfraemail/EmailUtil.java new file mode 100644 index 00000000..8f66d70a --- /dev/null +++ b/core/core-infra-email/src/main/java/com/sponus/coreinfraemail/EmailUtil.java @@ -0,0 +1,76 @@ +package com.sponus.coreinfraemail; + +import java.util.Random; + +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.stereotype.Component; + +import jakarta.mail.Message; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeMessage; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Component +@RequiredArgsConstructor +@Slf4j +public class EmailUtil { + + private final JavaMailSender emailSender; + + private static final Random RANDOM = new Random(); + + public String sendEmail(String to) throws Exception { + String code = createEmailCode(); + MimeMessage message = createEmail(to, code); + emailSender.send(message); + return code; + } + + private MimeMessage createEmail(String to, String code) throws Exception { + log.info("보내는 대상 : " + to); + log.info("인증 코드 : " + code); + MimeMessage message = emailSender.createMimeMessage(); + InternetAddress[] recipients = {new InternetAddress(to)}; + message.setRecipients(Message.RecipientType.TO, recipients); // 보내는 대상 + message.setSubject("Spon-us 인증 코드 발급입니다."); // 제목 + + String msgg = ""; + msgg += "
"; + msgg += "

Spon-us 인증 코드입니다.

"; // 동적으로 메시지 내용 변경 + msgg += "
"; + msgg += "
"; + msgg += "

인증 코드

"; + msgg += "
"; + msgg += "인증 코드 : "; + msgg += code + "

"; + msgg += "
"; + message.setText(msgg, "utf-8", "html"); // 내용 + message.setFrom(new InternetAddress("Spon-us_team", "Spon-us")); // 보내는 사람 + + return message; + } + + public static String createEmailCode() { + StringBuilder code = new StringBuilder(); + + for (int i = 0; i < 6; i++) { // 인증 코드 6자리 + int index = RANDOM.nextInt(3); // 0~2 까지 랜덤 + switch (index) { + case 0: + code.append((char)((RANDOM.nextInt(26)) + 97)); + // a~z (ex. 1+97=98 => (char)98 = 'b') + break; + case 1: + code.append((char)((RANDOM.nextInt(26)) + 65)); + // A~Z + break; + default: + code.append((RANDOM.nextInt(10))); + // 0~9 + break; + } + } + return code.toString(); + } +} diff --git a/core/core-infra-email/src/main/resources/application-email.yml b/core/core-infra-email/src/main/resources/application-email.yml new file mode 100644 index 00000000..af8e0cdc --- /dev/null +++ b/core/core-infra-email/src/main/resources/application-email.yml @@ -0,0 +1,14 @@ +mail: + smtp: + port: ${EMAIL_PORT} + auth: true + starttls: + required: true + enable: true + socketFactory: + class: javax.net.ssl.SSLSocketFactory + fallback: false + +AdminMail: + id: ${EMAIL_ID} + password: ${EMAIL_PASSWORD} diff --git a/core/core-infra-portone/build.gradle b/core/core-infra-portone/build.gradle new file mode 100644 index 00000000..6e812e69 --- /dev/null +++ b/core/core-infra-portone/build.gradle @@ -0,0 +1,13 @@ +dependencies { + + implementation project(':core:core-domain'); + + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + + // Iamport + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'com.github.iamport:iamport-rest-client-java:0.2.23' +} + +bootJar { enabled = false } +jar { enabled = true } diff --git a/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentErrorCode.java b/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentErrorCode.java new file mode 100644 index 00000000..55cbc6f3 --- /dev/null +++ b/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentErrorCode.java @@ -0,0 +1,29 @@ +package com.sponus.coreinfraportone; + +import org.springframework.http.HttpStatus; + +import com.sponus.coredomain.domain.common.ApiResponse; +import com.sponus.coredomain.domain.common.BaseErrorCode; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum PaymentErrorCode implements BaseErrorCode { + PAYMENT_ERROR(HttpStatus.BAD_REQUEST, "PAY4000", "결제 중 에러가 발생했습니다."), + + PROPOSE_ALREADY_PAID(HttpStatus.BAD_REQUEST, "PAY4001", "이미 결제된 제안입니다."), + + PROPOSE_NOT_FOUND(HttpStatus.NOT_FOUND, "PAY4002", "해당 제안이 존재하지 않습니다."), + INVALID_PROPOSED_ORGANIZATION(HttpStatus.BAD_REQUEST, "PAY4003", "제안을 받은 단체만 접근이 가능합니다."); + + private final HttpStatus httpStatus; + private final String code; + private final String message; + + @Override + public ApiResponse getErrorResponse() { + return ApiResponse.onFailure(code, message); + } +} diff --git a/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentException.java b/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentException.java new file mode 100644 index 00000000..5d5900ef --- /dev/null +++ b/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentException.java @@ -0,0 +1,15 @@ +package com.sponus.coreinfraportone; + +import com.sponus.coredomain.domain.common.BaseErrorCode; + +import lombok.Getter; + +@Getter +public class PaymentException extends RuntimeException { + + private final BaseErrorCode errorCode; + + public PaymentException(BaseErrorCode errorCode) { + this.errorCode = errorCode; + } +} diff --git a/api/src/main/java/com/sponus/sponusbe/domain/payment/dto/PaymentRequest.java b/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentRequest.java similarity index 65% rename from api/src/main/java/com/sponus/sponusbe/domain/payment/dto/PaymentRequest.java rename to core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentRequest.java index 3c29eac9..4032ecb1 100644 --- a/api/src/main/java/com/sponus/sponusbe/domain/payment/dto/PaymentRequest.java +++ b/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentRequest.java @@ -1,4 +1,4 @@ -package com.sponus.sponusbe.domain.payment.dto; +package com.sponus.coreinfraportone; public record PaymentRequest( String impUid, diff --git a/api/src/main/java/com/sponus/sponusbe/domain/payment/service/PaymentService.java b/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentUtil.java similarity index 77% rename from api/src/main/java/com/sponus/sponusbe/domain/payment/service/PaymentService.java rename to core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentUtil.java index e86626f3..8fd5c210 100644 --- a/api/src/main/java/com/sponus/sponusbe/domain/payment/service/PaymentService.java +++ b/core/core-infra-portone/src/main/java/com/sponus/coreinfraportone/PaymentUtil.java @@ -1,9 +1,7 @@ -package com.sponus.sponusbe.domain.payment.service; +package com.sponus.coreinfraportone; import java.io.IOException; -import javax.annotation.PostConstruct; - import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -15,10 +13,8 @@ import com.sponus.coredomain.domain.organization.Organization; import com.sponus.coredomain.domain.propose.Propose; import com.sponus.coredomain.domain.propose.repository.ProposeRepository; -import com.sponus.sponusbe.domain.payment.dto.PaymentRequest; -import com.sponus.sponusbe.domain.propose.exception.ProposeErrorCode; -import com.sponus.sponusbe.domain.propose.exception.ProposeException; +import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -26,7 +22,7 @@ @Service @Transactional @RequiredArgsConstructor -public class PaymentService { +public class PaymentUtil { @Value("${PORT_ONE_KEY}") private String restApiKey; @@ -45,12 +41,12 @@ public Payment paymentByImpUid(PaymentRequest request, Organization authOrganiza try { log.info("Payment Request : {}", request.toString()); final Propose propose = proposeRepository.findById(request.proposeId()) - .orElseThrow(() -> new ProposeException(ProposeErrorCode.PROPOSE_NOT_FOUND)); + .orElseThrow(() -> new PaymentException(PaymentErrorCode.PROPOSE_NOT_FOUND)); if (!isProposingOrganization(propose, authOrganization)) { - throw new ProposeException(ProposeErrorCode.INVALID_PROPOSING_ORGANIZATION); + throw new PaymentException(PaymentErrorCode.INVALID_PROPOSED_ORGANIZATION); } if (propose.isPaid()) { - throw new ProposeException(ProposeErrorCode.PROPOSE_ALREADY_PAID); + throw new PaymentException(PaymentErrorCode.PROPOSE_ALREADY_PAID); } propose.updateToPaid(request.impUid()); final IamportResponse paymentIamportResponse = iamportClient.paymentByImpUid(request.impUid()); @@ -58,7 +54,7 @@ public Payment paymentByImpUid(PaymentRequest request, Organization authOrganiza return paymentIamportResponse.getResponse(); } catch (IamportResponseException | IOException e) { log.error("Payment Error : {}", e.getMessage()); - throw new ProposeException(ProposeErrorCode.PAYMENT_ERROR); + throw new PaymentException(PaymentErrorCode.PAYMENT_ERROR); } } diff --git a/core/core-infra-portone/src/main/resources/application-portone.yml b/core/core-infra-portone/src/main/resources/application-portone.yml new file mode 100644 index 00000000..77e26fcf --- /dev/null +++ b/core/core-infra-portone/src/main/resources/application-portone.yml @@ -0,0 +1,2 @@ +PORT_ONE_KEY: ${PORT_ONE_KEY} +PORT_ONE_SECRET: ${PORT_ONE_SECRET} diff --git a/api/out/production/resources/templates/payment.html b/core/core-infra-portone/src/main/resources/templates/payment.html similarity index 100% rename from api/out/production/resources/templates/payment.html rename to core/core-infra-portone/src/main/resources/templates/payment.html diff --git a/settings.gradle b/settings.gradle index 4c44e610..b420afa4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,3 +4,5 @@ include 'core:core-domain' include 'core:core-infra-db' include 'core:core-infra-s3' include 'core:core-infra-redis' +include 'core:core-infra-email' +include 'core:core-infra-portone'