|
@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
@ -74,6 +75,9 @@ public class SsoServiceImpl implements SsoService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${epmet.third.urlPrefix}") |
|
|
|
|
|
private String epmetThirdUrlPrefix; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 0、入口:得到token |
|
|
* @Description 0、入口:得到token |
|
|
* @Param formDTO |
|
|
* @Param formDTO |
|
@ -81,8 +85,9 @@ public class SsoServiceImpl implements SsoService { |
|
|
* @date 2021/1/18 下午4:59 |
|
|
* @date 2021/1/18 下午4:59 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO) { |
|
|
public SsoLoginResultDTO ssoResiLogin(SsoLoginFormDTO formDTO) { |
|
|
String customerId = getCustomerId(formDTO.getAppId()); |
|
|
String customerId = getCustomerId(formDTO.getAppId()); |
|
|
|
|
|
//String customerId = "3a4f923665a7a07701bcb311aac9a156";
|
|
|
String userId = ""; |
|
|
String userId = ""; |
|
|
|
|
|
|
|
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); |
|
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); |
|
@ -97,7 +102,7 @@ public class SsoServiceImpl implements SsoService { |
|
|
ThirdPlatUserInfo userInfo; |
|
|
ThirdPlatUserInfo userInfo; |
|
|
try { |
|
|
try { |
|
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
|
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
|
|
userInfo = apiService.getUserInfoByTicket(formDTO.getTicket()); |
|
|
userInfo = apiService.getCUserInfoByTicket(formDTO.getTicket()); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
throw new RenException(e.getMessage()); |
|
|
throw new RenException(e.getMessage()); |
|
|
} |
|
|
} |
|
@ -139,7 +144,7 @@ public class SsoServiceImpl implements SsoService { |
|
|
ThirdPlatformEnum platformEnum = ThirdPlatformEnum.getEnum(formDTO.getPlatform()); |
|
|
ThirdPlatformEnum platformEnum = ThirdPlatformEnum.getEnum(formDTO.getPlatform()); |
|
|
String apiService = platformEnum.getApiService(); |
|
|
String apiService = platformEnum.getApiService(); |
|
|
AbstractApiService apiServiceImpl = (AbstractApiService) SpringContextUtils.getBean(apiService); |
|
|
AbstractApiService apiServiceImpl = (AbstractApiService) SpringContextUtils.getBean(apiService); |
|
|
thirdUser = apiServiceImpl.getUserInfoByTicket(formDTO.getThirdToken()); |
|
|
thirdUser = apiServiceImpl.getGUserInfoBySSOToken(formDTO.getThirdToken()); |
|
|
} catch (RenException e) { |
|
|
} catch (RenException e) { |
|
|
throw new RenException(e.getCode(), e.getMessage()); |
|
|
throw new RenException(e.getCode(), e.getMessage()); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
@ -229,7 +234,7 @@ public class SsoServiceImpl implements SsoService { |
|
|
*/ |
|
|
*/ |
|
|
public String getCustomerId(String appId){ |
|
|
public String getCustomerId(String appId){ |
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
String customerMsgUrl = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/"; |
|
|
String customerMsgUrl = epmetThirdUrlPrefix + "/api/third/customermp/getcustomermsg/"; |
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(customerMsgUrl + appId, JSON.toJSONString(jsonObject)).getData(); |
|
|
String data = HttpClientManager.getInstance().sendPostByJSON(customerMsgUrl + appId, JSON.toJSONString(jsonObject)).getData(); |
|
|
log.info("调用third服务,根据appId查询客户信息:httpclient->url:" + customerMsgUrl + ",结果->" + data); |
|
|
log.info("调用third服务,根据appId查询客户信息:httpclient->url:" + customerMsgUrl + ",结果->" + data); |
|
|
JSONObject toResult = JSON.parseObject(data); |
|
|
JSONObject toResult = JSON.parseObject(data); |
|
@ -255,10 +260,11 @@ public class SsoServiceImpl implements SsoService { |
|
|
* @Description 1、ticket自动登录获取内部token |
|
|
* @Description 1、ticket自动登录获取内部token |
|
|
**/ |
|
|
**/ |
|
|
@Override |
|
|
@Override |
|
|
public UserTokenResultDTO ssoWorkLogin(SsoLoginFormDTO formDTO) { |
|
|
public UserTokenResultDTO ssoWorkLogin(SsoWorkLoginFormDTO formDTO) { |
|
|
|
|
|
|
|
|
//1.根据appId查询客户id
|
|
|
//1.根据appId查询客户id
|
|
|
String customerId = getCustomerId(formDTO.getAppId()); |
|
|
String customerId = getCustomerId(formDTO.getAppId()); |
|
|
|
|
|
//String customerId = "3a4f923665a7a07701bcb311aac9a156";
|
|
|
|
|
|
|
|
|
//2.客户Id换取第三方apiService,根据ticket换取华为Id
|
|
|
//2.客户Id换取第三方apiService,根据ticket换取华为Id
|
|
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); |
|
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); |
|
@ -271,7 +277,7 @@ public class SsoServiceImpl implements SsoService { |
|
|
ThirdPlatUserInfo userInfo; |
|
|
ThirdPlatUserInfo userInfo; |
|
|
try { |
|
|
try { |
|
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
|
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
|
|
userInfo = apiService.getUserInfoByTicket(formDTO.getTicket()); |
|
|
userInfo = apiService.getGUserInfoBySSOToken(formDTO.getToken()); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
throw new RenException(e.getMessage()); |
|
|
throw new RenException(e.getMessage()); |
|
|
} |
|
|
} |
|
@ -353,7 +359,7 @@ public class SsoServiceImpl implements SsoService { |
|
|
int expire = jwtTokenProperties.getExpire(); |
|
|
int expire = jwtTokenProperties.getExpire(); |
|
|
GovTokenDto govTokenDto = new GovTokenDto(); |
|
|
GovTokenDto govTokenDto = new GovTokenDto(); |
|
|
govTokenDto.setApp(LoginConstant.APP_GOV); |
|
|
govTokenDto.setApp(LoginConstant.APP_GOV); |
|
|
govTokenDto.setClient(LoginConstant.CLIENT_WXMP); |
|
|
govTokenDto.setClient(LoginConstant.CLIENT_APP); |
|
|
govTokenDto.setUserId(staffLatestAgency.getStaffId()); |
|
|
govTokenDto.setUserId(staffLatestAgency.getStaffId()); |
|
|
govTokenDto.setOpenId(userInfo.getOpenId()); |
|
|
govTokenDto.setOpenId(userInfo.getOpenId()); |
|
|
govTokenDto.setSessionKey(""); |
|
|
govTokenDto.setSessionKey(""); |
|
@ -479,21 +485,21 @@ public class SsoServiceImpl implements SsoService { |
|
|
//2.客户Id换取第三方apiService,根据ticket换取华为Id
|
|
|
//2.客户Id换取第三方apiService,根据ticket换取华为Id
|
|
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(formDTO.getCustomerId())); |
|
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(formDTO.getCustomerId())); |
|
|
if (!apiServiceResult.success()) { |
|
|
if (!apiServiceResult.success()) { |
|
|
throw new RenException("【SSO登录】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg()); |
|
|
throw new RenException("【SSO enterOrg】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg()); |
|
|
} |
|
|
} |
|
|
if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) { |
|
|
if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) { |
|
|
throw new RenException("【SSO登录】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString()); |
|
|
throw new RenException("【SSO enterOrg】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString()); |
|
|
} |
|
|
} |
|
|
ThirdPlatUserInfo userInfo; |
|
|
ThirdPlatUserInfo userInfo; |
|
|
try { |
|
|
try { |
|
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
|
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
|
|
userInfo = apiService.getUserInfoByTicket(formDTO.getTicket()); |
|
|
userInfo = apiService.getGUserInfoBySSOToken(formDTO.getToken()); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
throw new RenException(e.getMessage()); |
|
|
throw new RenException(e.getMessage()); |
|
|
} |
|
|
} |
|
|
if (null == userInfo){ |
|
|
if (null == userInfo){ |
|
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
|
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
|
|
"【SSO登录】调用第三方平台查询用户信息失败,用户信息为空"); |
|
|
"【SSO enterOrg】调用第三方平台查询用户信息失败,用户信息为空"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//3、记录staff_wechat,并记录用户激活状态,激活时间
|
|
|
//3、记录staff_wechat,并记录用户激活状态,激活时间
|
|
|