|
@ -127,7 +127,7 @@ public class LoginServiceImpl implements LoginService { |
|
|
WxLoginUserInfoFormDTO wxLoginUserInfoFormDTO=new WxLoginUserInfoFormDTO(); |
|
|
WxLoginUserInfoFormDTO wxLoginUserInfoFormDTO=new WxLoginUserInfoFormDTO(); |
|
|
wxLoginUserInfoFormDTO.setApp(formDTO.getApp()); |
|
|
wxLoginUserInfoFormDTO.setApp(formDTO.getApp()); |
|
|
wxLoginUserInfoFormDTO.setOpenId(wxMaJscode2SessionResult.getOpenid()); |
|
|
wxLoginUserInfoFormDTO.setOpenId(wxMaJscode2SessionResult.getOpenid()); |
|
|
Result userResult=epmetUserFeignClient.selecWxLoginUserInfo(wxLoginUserInfoFormDTO); |
|
|
Result<String> userResult=epmetUserFeignClient.selecWxLoginUserInfo(wxLoginUserInfoFormDTO); |
|
|
String userId=""; |
|
|
String userId=""; |
|
|
if(!userResult.success()){ |
|
|
if(!userResult.success()){ |
|
|
throw new RenException("获取用户信息失败"+userResult.getMsg()); |
|
|
throw new RenException("获取用户信息失败"+userResult.getMsg()); |
|
@ -136,13 +136,31 @@ public class LoginServiceImpl implements LoginService { |
|
|
if (StringUtils.isBlank(userId)&&LoginConstant.APP_GOV.equals(formDTO.getApp())) { |
|
|
if (StringUtils.isBlank(userId)&&LoginConstant.APP_GOV.equals(formDTO.getApp())) { |
|
|
//查询customer_staff待完善
|
|
|
//查询customer_staff待完善
|
|
|
} else if (StringUtils.isBlank(userId)&&LoginConstant.APP_OPER.equals(formDTO.getApp())) { |
|
|
} else if (StringUtils.isBlank(userId)&&LoginConstant.APP_OPER.equals(formDTO.getApp())) { |
|
|
//查询oper_staff待完善
|
|
|
//查询oper_user待完善
|
|
|
} else if (StringUtils.isBlank(userId)&&LoginConstant.APP_RESI.equals(formDTO.getApp())) { |
|
|
} else if (StringUtils.isBlank(userId)&&LoginConstant.APP_RESI.equals(formDTO.getApp())) { |
|
|
//查询customer_user
|
|
|
//查询customer_user
|
|
|
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.resiWxMaService().getUserService() |
|
|
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.resiWxMaService().getUserService() |
|
|
.getUserInfo(wxMaJscode2SessionResult.getSessionKey(), |
|
|
.getUserInfo(wxMaJscode2SessionResult.getSessionKey(), |
|
|
formDTO.getEncryptedData(), |
|
|
formDTO.getEncryptedData(), |
|
|
formDTO.getIv()); |
|
|
formDTO.getIv()); |
|
|
|
|
|
CustomerUserDTO customerUserDTO=this.packageCustomerUserDTO(wxMaUserInfo); |
|
|
|
|
|
Result<String> saveCustomerUserResult=epmetUserFeignClient.saveCustomerUser(customerUserDTO); |
|
|
|
|
|
if(!saveCustomerUserResult.success()){ |
|
|
|
|
|
throw new RenException("创建用户失败"+userResult.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
userId = saveCustomerUserResult.getData(); |
|
|
|
|
|
} |
|
|
|
|
|
return userId; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param wxMaUserInfo |
|
|
|
|
|
* @return com.epmet.dto.CustomerUserDTO |
|
|
|
|
|
* @Author yinzuomei |
|
|
|
|
|
* @Description 微信信息封装为customer_user记录 |
|
|
|
|
|
* @Date 2020/3/17 18:22 |
|
|
|
|
|
**/ |
|
|
|
|
|
private CustomerUserDTO packageCustomerUserDTO(WxMaUserInfo wxMaUserInfo) { |
|
|
CustomerUserDTO customerUserDTO = new CustomerUserDTO(); |
|
|
CustomerUserDTO customerUserDTO = new CustomerUserDTO(); |
|
|
customerUserDTO.setCity(wxMaUserInfo.getCity()); |
|
|
customerUserDTO.setCity(wxMaUserInfo.getCity()); |
|
|
customerUserDTO.setWxOpenId(wxMaUserInfo.getOpenId()); |
|
|
customerUserDTO.setWxOpenId(wxMaUserInfo.getOpenId()); |
|
@ -152,13 +170,7 @@ public class LoginServiceImpl implements LoginService { |
|
|
customerUserDTO.setCountry(wxMaUserInfo.getCountry()); |
|
|
customerUserDTO.setCountry(wxMaUserInfo.getCountry()); |
|
|
customerUserDTO.setProvince(wxMaUserInfo.getProvince()); |
|
|
customerUserDTO.setProvince(wxMaUserInfo.getProvince()); |
|
|
customerUserDTO.setSex(Integer.valueOf(wxMaUserInfo.getGender())); |
|
|
customerUserDTO.setSex(Integer.valueOf(wxMaUserInfo.getGender())); |
|
|
Result<String> saveCustomerUserResult=epmetUserFeignClient.saveCustomerUser(customerUserDTO); |
|
|
return customerUserDTO; |
|
|
if(!saveCustomerUserResult.success()){ |
|
|
|
|
|
throw new RenException("创建用户失败"+userResult.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
userId = saveCustomerUserResult.getData(); |
|
|
|
|
|
} |
|
|
|
|
|
return userId; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -180,7 +192,7 @@ public class LoginServiceImpl implements LoginService { |
|
|
map.put("client", formDTO.getClient()); |
|
|
map.put("client", formDTO.getClient()); |
|
|
map.put("userId", userId); |
|
|
map.put("userId", userId); |
|
|
String token = jwtTokenUtils.createToken(map); |
|
|
String token = jwtTokenUtils.createToken(map); |
|
|
logger.info("日志输出token="+token); |
|
|
logger.info("app:"+formDTO.getApp()+"client:"+formDTO.getClient()+"userId:"+userId+"生成token["+token+"]"); |
|
|
int expire = jwtTokenProperties.getExpire(); |
|
|
int expire = jwtTokenProperties.getExpire(); |
|
|
TokenDto tokenDto = new TokenDto(); |
|
|
TokenDto tokenDto = new TokenDto(); |
|
|
tokenDto.setApp(formDTO.getApp()); |
|
|
tokenDto.setApp(formDTO.getApp()); |
|
@ -189,7 +201,7 @@ public class LoginServiceImpl implements LoginService { |
|
|
tokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); |
|
|
tokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); |
|
|
tokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); |
|
|
tokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); |
|
|
tokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid()); |
|
|
tokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid()); |
|
|
cpUserDetailRedis.set(tokenDto, expire); |
|
|
cpUserDetailRedis.set(token,tokenDto, expire); |
|
|
return token; |
|
|
return token; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -220,10 +232,10 @@ public class LoginServiceImpl implements LoginService { |
|
|
} |
|
|
} |
|
|
//2、密码是否正确
|
|
|
//2、密码是否正确
|
|
|
//密码错误
|
|
|
//密码错误
|
|
|
if(!PasswordUtils.matches(userInfoResult.getData().getPassword(), formDTO.getPassword())){ |
|
|
if(!PasswordUtils.matches(userInfoResult.getData().getPassWord(), formDTO.getPassword())){ |
|
|
throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR); |
|
|
throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR); |
|
|
} |
|
|
} |
|
|
if(!userInfoResult.getData().getPassword().equals(formDTO.getPassword())){ |
|
|
if(!userInfoResult.getData().getPassWord().equals(formDTO.getPassword())){ |
|
|
throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR); |
|
|
throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR); |
|
|
} |
|
|
} |
|
|
//3、生成token返回,且将TokenDto存到redis
|
|
|
//3、生成token返回,且将TokenDto存到redis
|
|
@ -249,13 +261,13 @@ public class LoginServiceImpl implements LoginService { |
|
|
map.put("client", formDTO.getClient()); |
|
|
map.put("client", formDTO.getClient()); |
|
|
map.put("userId", userId); |
|
|
map.put("userId", userId); |
|
|
String token = jwtTokenUtils.createToken(map); |
|
|
String token = jwtTokenUtils.createToken(map); |
|
|
logger.info("日志输出token="+token); |
|
|
logger.info("app:"+formDTO.getApp()+"client:"+formDTO.getClient()+"userId:"+userId+"生成token["+token+"]"); |
|
|
int expire = jwtTokenProperties.getExpire(); |
|
|
int expire = jwtTokenProperties.getExpire(); |
|
|
TokenDto tokenDto = new TokenDto(); |
|
|
TokenDto tokenDto = new TokenDto(); |
|
|
tokenDto.setApp(formDTO.getApp()); |
|
|
tokenDto.setApp(formDTO.getApp()); |
|
|
tokenDto.setClient(formDTO.getClient()); |
|
|
tokenDto.setClient(formDTO.getClient()); |
|
|
tokenDto.setUserId(userId); |
|
|
tokenDto.setUserId(userId); |
|
|
cpUserDetailRedis.set(tokenDto, expire); |
|
|
cpUserDetailRedis.set(token,tokenDto, expire); |
|
|
return token; |
|
|
return token; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|