From 33d0d51a799302ebc3ff47b86dbce4c1912abd22 Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期二, 30 十一月 2021 10:10:43 +0800
Subject: [PATCH] [update] 【todo 131218】嚴選配對 與 快速篩選 的滿意度評分皆改成 列出指定滿意度評分以上的顧問

---
 pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java b/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java
index 0f7db32..0a3db3b 100644
--- a/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java
+++ b/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java
@@ -1,15 +1,14 @@
 package com.pollex.pam.security.provider;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.pollex.pam.config.ApplicationProperties;
 import com.pollex.pam.domain.Consultant;
 import com.pollex.pam.enums.ConsultantDetailEnum;
-import com.pollex.pam.enums.CustomerDetailEnum;
 import com.pollex.pam.repository.ConsultantRepository;
 import com.pollex.pam.security.token.EServiceAuthenticationToken;
-import com.pollex.pam.service.dto.EServiceRequest;
+import com.pollex.pam.service.LoginRecordService;
 import com.pollex.pam.service.dto.EServiceResponse;
+import com.pollex.pam.web.rest.errors.EServiceErrorException;
 import org.apache.http.conn.ssl.NoopHostnameVerifier;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -22,7 +21,6 @@
 import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
 import org.springframework.security.authentication.AuthenticationServiceException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
@@ -54,11 +52,15 @@
     @Autowired
     ConsultantRepository consultantRepository;
 
+    @Autowired
+    LoginRecordService loginRecordService;
+
     public Authentication authenticate(EServiceAuthenticationToken authenticationToken) throws AuthenticationException {
         String account = authenticationToken.getPrincipal();
         String credentials = authenticationToken.getCredentials();
 
         if(applicationProperty.isMockLogin()){
+            loginRecordService.saveEServiceLoginSuccessRecord(account);
             return getConsultantToken(account, credentials);
         }
 
@@ -68,17 +70,20 @@
                 EServiceResponse eServiceResponse = responseEntity.getBody();
 
                 if(E_SERVICE_LOGIN_SUCCESS_CODE.equals(eServiceResponse.getCode())){
+                    loginRecordService.saveEServiceLoginSuccessRecord(account);
                     return getConsultantToken(account, credentials);
                 }
-
-                throw new RuntimeException("eService login failed, eService response code = " + eServiceResponse.getCode() + ", eService response msg = " + eServiceResponse.getMsg());
+                else {
+                    loginRecordService.saveEServiceLoginFailRecord(account, eServiceResponse.getMsg());
+                    throw new EServiceErrorException(eServiceResponse.getMsg());
+                }
             }
 
             throw new RuntimeException("eService http error!, response http status code = " + responseEntity.getStatusCode());
         } catch (JsonProcessingException e) {
-            throw new AuthenticationServiceException("convert to json processing error!");
+            throw new RuntimeException("convert to json processing error!");
         } catch (GeneralSecurityException e) {
-            throw new AuthenticationServiceException("General Security SSL error!");
+            throw new RuntimeException("General Security SSL error!");
         }
     }
 

--
Gitblit v1.8.0