Skip to content

Commit

Permalink
Merge pull request #145 from capstone-kw-jjiggle/feature/#144-univCer…
Browse files Browse the repository at this point in the history
…tClearUser

[feat] #144 - 학교 인증 처리할때 인증 성공했을 경우 인증 리스트 초기화 하여 이후 회원탈퇴에도 문제 없게 진행
  • Loading branch information
khyojun authored Jun 18, 2024
2 parents 334bf9c + 8909e3c commit 43f0ae1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/gitbal/backend/api/univcert/service/UnivService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -30,13 +33,23 @@ public UnivCertResponseDto certStart(UnivCertStartDto univCertStartDto){
public UnivCertResponseDto certCode(UnivCertCodeDto univCertCodeDto) {
try {
Map<String, Object> 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<String, Object> response, String email) throws IOException {
Map<String, Object> 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<String, Object> univCertResponse, String successMessage) {
boolean success = Boolean.TRUE.equals(univCertResponse.get("success"));
int status = success ? 200 : (Integer) univCertResponse.get("code");
Expand Down

0 comments on commit 43f0ae1

Please sign in to comment.