|
|
|
@ -645,7 +645,6 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
TokenDto tokenDto = ConvertUtils.sourceToTarget(userResult.getUserDTO(), TokenDto.class); |
|
|
|
tokenDto.setUserId(userResult.getUserDTO().getId()); |
|
|
|
EpdcAppAuthorizationDTO authorization = this.packageEpdcAppAuthorization(tokenDto, userResult.getGrid(), userResult.getUserDTO().getState()); |
|
|
|
authorization.setUserState(userResult.getUserDTO().getState()); |
|
|
|
|
|
|
|
return new Result<EpdcAppAuthorizationDTO>().ok(authorization); |
|
|
|
} |
|
|
|
@ -796,7 +795,61 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
gridRelationDTO.setGrid(completeDept.getGrid()); |
|
|
|
gridRelationDTO.setGridId(completeDept.getGridId()); |
|
|
|
gridRelationDTO.setSwitchedTime(new Date()); |
|
|
|
gridRelationDTO.setLeaderFlag(NumConstant.ZERO_STR); |
|
|
|
|
|
|
|
return gridRelationDTO; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result updateWxInfo(TokenDto userDetail, EpdcAppUserMaInfoFormDTO formDto) { |
|
|
|
if (null == userDetail || StringUtils.isEmpty(userDetail.getUserId())) { |
|
|
|
return new Result().error("获取用户信息失败"); |
|
|
|
} |
|
|
|
String sessionKey = this.getUserSessionKey(formDto.getWxCode()); |
|
|
|
WxMaUserInfo wxMaUserInfo = wxMaService.getUserService().getUserInfo(sessionKey, formDto.getEncryptedData(), formDto.getIv()); |
|
|
|
UserDTO userDTO = new UserDTO(); |
|
|
|
userDTO.setId(userDetail.getUserId()); |
|
|
|
userDTO.setNickname(wxMaUserInfo.getNickName()); |
|
|
|
userDTO.setFaceImg(wxMaUserInfo.getAvatarUrl()); |
|
|
|
userDTO.setSex(wxMaUserInfo.getGender()); |
|
|
|
Result updateWxInfoResult = userFeignClient.updateWxInfo(userDTO); |
|
|
|
if (!updateWxInfoResult.success()) { |
|
|
|
return new Result().error("更新用户信息失败"); |
|
|
|
} |
|
|
|
|
|
|
|
// 更新用户缓存信息
|
|
|
|
TokenDto tokenDto = ConvertUtils.sourceToTarget(userDTO, TokenDto.class); |
|
|
|
tokenDto.setUserId(userDetail.getUserId()); |
|
|
|
tokenDto.setGridId(userDetail.getGridId()); |
|
|
|
tokenDto.setMobile(userDetail.getMobile()); |
|
|
|
tokenDto.setPartyFlag(userDetail.getPartyFlag()); |
|
|
|
tokenDto.setRealName(userDetail.getRealName()); |
|
|
|
long expire = cpUserDetailRedis.getExpire(userDetail.getUserId()); |
|
|
|
cpUserDetailRedis.logout(userDetail.getUserId()); |
|
|
|
cpUserDetailRedis.set(tokenDto, expire); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* 根据微信code获取session_key |
|
|
|
* |
|
|
|
* @params [code] |
|
|
|
* @return java.lang.String |
|
|
|
* @author liuchuang |
|
|
|
* @since 2019/10/25 16:31 |
|
|
|
*/ |
|
|
|
private String getUserSessionKey(String code) { |
|
|
|
try { |
|
|
|
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(code); |
|
|
|
if (wxMaJscode2SessionResult != null) { |
|
|
|
return wxMaJscode2SessionResult.getSessionKey(); |
|
|
|
} |
|
|
|
} catch (WxErrorException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
throw new RenException(e.getError().getErrorMsg()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|