From 8909e3ca3511a76d8953c5ff107992a210127ba7 Mon Sep 17 00:00:00 2001 From: Khyojun Date: Tue, 18 Jun 2024 14:50:45 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20#144=20-=20=ED=95=99=EA=B5=90=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=B2=98=EB=A6=AC=ED=95=A0=EB=95=8C=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=84=B1=EA=B3=B5=ED=96=88=EC=9D=84=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=9D=B8=EC=A6=9D=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B4=88=EA=B8=B0=ED=99=94=20=ED=95=98=EC=97=AC=20?= =?UTF-8?q?=EC=9D=B4=ED=9B=84=20=ED=9A=8C=EC=9B=90=ED=83=88=ED=87=B4?= =?UTF-8?q?=EC=97=90=EB=8F=84=20=EB=AC=B8=EC=A0=9C=20=EC=97=86=EA=B2=8C=20?= =?UTF-8?q?=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/univcert/service/UnivService.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/gitbal/backend/api/univcert/service/UnivService.java b/src/main/java/gitbal/backend/api/univcert/service/UnivService.java index 50c9d20..28f59a6 100644 --- a/src/main/java/gitbal/backend/api/univcert/service/UnivService.java +++ b/src/main/java/gitbal/backend/api/univcert/service/UnivService.java @@ -6,13 +6,16 @@ import gitbal.backend.api.univcert.dto.UnivCertStartDto; import gitbal.backend.global.exception.UnivCertCodeException; import gitbal.backend.global.exception.UnivCertStartException; +import java.io.IOException; +import java.util.HashMap; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.util.HashMap; import java.util.Map; @Service +@Slf4j public class UnivService { @Value("${API-KEY}") @@ -30,13 +33,23 @@ public UnivCertResponseDto certStart(UnivCertStartDto univCertStartDto){ public UnivCertResponseDto certCode(UnivCertCodeDto univCertCodeDto) { try { Map response = UnivCert.certifyCode(apikey, univCertCodeDto.getEmail(), univCertCodeDto.getUnivName(), univCertCodeDto.getCode()); - return responsetoDto(response, "인증 성공"); + clearCertifiedList(response, univCertCodeDto.getEmail()); + + return responsetoDto(response, "인증 성공"); } catch (Exception e) { throw new UnivCertCodeException(); } } + private void clearCertifiedList(Map response, String email) throws IOException { + Map clear = new HashMap<>(); + if(Boolean.TRUE.equals(response.get("success"))) clear = UnivCert.clear(apikey,email); + else log.info("[clearResponse] 인증 과정에서 코드가 맞지 않아 clear하지 않았습니다."); + if(Boolean.TRUE.equals(clear.get("success"))) log.info("[clearResponse] clear success"); + else log.error("[clearResponse] clear fail"); + } + private UnivCertResponseDto responsetoDto(Map univCertResponse, String successMessage) { boolean success = Boolean.TRUE.equals(univCertResponse.get("success")); int status = success ? 200 : (Integer) univCertResponse.get("code");