|
@ -86,6 +86,9 @@ public class SsoServiceImpl implements SsoService { |
|
|
@Resource |
|
|
@Resource |
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ThirdLoginServiceImpl thirdLoginService; |
|
|
|
|
|
|
|
|
@Value("${epmet.third.urlPrefix}") |
|
|
@Value("${epmet.third.urlPrefix}") |
|
|
private String epmetThirdUrlPrefix; |
|
|
private String epmetThirdUrlPrefix; |
|
|
|
|
|
|
|
@ -230,8 +233,7 @@ public class SsoServiceImpl implements SsoService { |
|
|
String mobile = data.getString("phone"); |
|
|
String mobile = data.getString("phone"); |
|
|
//1、根据手机号查询政府端工作人员基本信息,校验用户是否存在
|
|
|
//1、根据手机号查询政府端工作人员基本信息,校验用户是否存在
|
|
|
Result<List<CustomerStaffDTO>> staffData = epmetUserFeignClient.checkCustomerStaff(mobile); |
|
|
Result<List<CustomerStaffDTO>> staffData = epmetUserFeignClient.checkCustomerStaff(mobile); |
|
|
String customerId = ""; |
|
|
String customerId = "", userId = ""; |
|
|
String userId = ""; |
|
|
|
|
|
if (null != staffData && staffData.getData().size() > 0) { |
|
|
if (null != staffData && staffData.getData().size() > 0) { |
|
|
//2、根据客户Id和手机号查询登陆用户信息(代码逻辑来源于web端登陆接口)
|
|
|
//2、根据客户Id和手机号查询登陆用户信息(代码逻辑来源于web端登陆接口)
|
|
|
CustomerStaffDTO staffDTO = staffData.getData().get(0); |
|
|
CustomerStaffDTO staffDTO = staffData.getData().get(0); |
|
@ -255,9 +257,8 @@ public class SsoServiceImpl implements SsoService { |
|
|
//5.生成token存到redis并返回
|
|
|
//5.生成token存到redis并返回
|
|
|
userTokenResultDTO = new UserTokenResultDTO(); |
|
|
userTokenResultDTO = new UserTokenResultDTO(); |
|
|
userTokenResultDTO.setCustomerId(customerId); |
|
|
userTokenResultDTO.setCustomerId(customerId); |
|
|
String token = generateToken(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WEB, userId); |
|
|
String token = ssoGetToken(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_SSO, userId, customerId); |
|
|
userTokenResultDTO.setToken(token); |
|
|
userTokenResultDTO.setToken(token); |
|
|
disposeTokenDto(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WEB, userId, token, customerId); |
|
|
|
|
|
// 6.发送登录事件
|
|
|
// 6.发送登录事件
|
|
|
try { |
|
|
try { |
|
|
SpringContextUtils.getBean(ThirdLoginService.class).sendLoginEvent(userId, "数字社区登录", |
|
|
SpringContextUtils.getBean(ThirdLoginService.class).sendLoginEvent(userId, "数字社区登录", |
|
@ -337,6 +338,38 @@ public class SsoServiceImpl implements SsoService { |
|
|
return token; |
|
|
return token; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String ssoGetToken(String app, String client, String userId, String customerId) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
map.put("app", app); |
|
|
|
|
|
map.put("client", client); |
|
|
|
|
|
map.put("userId", userId); |
|
|
|
|
|
String token = jwtTokenUtils.createToken(map); |
|
|
|
|
|
log.info("app:" + app + ";client:" + client + ";userId:" + userId + ";生成token[" + token + "]"); |
|
|
|
|
|
int expire = jwtTokenProperties.getExpire(); |
|
|
|
|
|
|
|
|
|
|
|
String orgIdPath = thirdLoginService.getOrgIdPath(userId); |
|
|
|
|
|
String[] orgIdPathParts = orgIdPath.split(":"); |
|
|
|
|
|
|
|
|
|
|
|
GovTokenDto tokenDto = new GovTokenDto(); |
|
|
|
|
|
tokenDto.setCustomerId(customerId); |
|
|
|
|
|
tokenDto.setApp(app); |
|
|
|
|
|
tokenDto.setClient(client); |
|
|
|
|
|
tokenDto.setUserId(userId); |
|
|
|
|
|
tokenDto.setToken(token); |
|
|
|
|
|
tokenDto.setUpdateTime(System.currentTimeMillis()); |
|
|
|
|
|
tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); |
|
|
|
|
|
tokenDto.setAgencyId(orgIdPathParts[orgIdPathParts.length - 1]); |
|
|
|
|
|
tokenDto.setRootAgencyId(orgIdPathParts[0]); |
|
|
|
|
|
tokenDto.setDeptIdList(thirdLoginService.getDeptartmentIdList(userId)); |
|
|
|
|
|
tokenDto.setGridIdList(thirdLoginService.getGridIdList(userId)); |
|
|
|
|
|
tokenDto.setRoleList(thirdLoginService.queryGovStaffRoles(userId, orgIdPathParts[orgIdPathParts.length - 1])); |
|
|
|
|
|
tokenDto.setOrgIdPath(orgIdPath); |
|
|
|
|
|
|
|
|
|
|
|
cpUserDetailRedis.set(tokenDto, expire); |
|
|
|
|
|
log.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
|
return token; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 获取customerId |
|
|
* @Description 获取customerId |
|
|
* @Param appId |
|
|
* @Param appId |
|
|