|
|
|
|
@ -16,6 +16,7 @@ import com.flossom.miniProgram.domain.vo.*;
|
|
|
|
|
import com.flossom.miniProgram.service.IWxUserMemberService;
|
|
|
|
|
import com.flossom.miniProgram.utils.MiniProgramUtils;
|
|
|
|
|
import com.flossom.system.api.RemoteAuthService;
|
|
|
|
|
import com.flossom.system.api.model.LoginUser;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
@ -127,6 +128,40 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
|
|
|
|
|
BeanUtils.copyProperties(userMemberUpdateVo, wxUserMember);
|
|
|
|
|
wxUserMember.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
wxUserMemberMapper.updateWxUserMember(wxUserMember);
|
|
|
|
|
|
|
|
|
|
// 重新构建用户信息缓存
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重构用户缓存信息
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public LoginUserVo refreshWxUserInfo() {
|
|
|
|
|
// 1、获取用户最新信息
|
|
|
|
|
String openid = SecurityUtils.getLoginUser().getWxUserMember().getOpenid();
|
|
|
|
|
WxUserMember wxUserMember = wxUserMemberMapper.selectWxUserMemberByOpenId(openid);
|
|
|
|
|
if (wxUserMember == null) {
|
|
|
|
|
logger.error("刷新用户信息失败");
|
|
|
|
|
throw new ServiceException("刷新用户信息失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2、刷新redis缓存信息
|
|
|
|
|
String userKey = SecurityUtils.getUserKey();
|
|
|
|
|
LoginUser loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + userKey);
|
|
|
|
|
loginUser.setWxUserMember(wxUserMember);
|
|
|
|
|
loginUser.setWxUserid(wxUserMember.getId());
|
|
|
|
|
loginUser.setUsername(wxUserMember.getNickname());
|
|
|
|
|
loginUser.setExpireTime(loginUser.getLoginTime() + CacheConstants.EXPIRATION * 60 * 1000);
|
|
|
|
|
redisService.setCacheObject(userKey, loginUser, CacheConstants.EXPIRATION, TimeUnit.MINUTES);
|
|
|
|
|
|
|
|
|
|
// 3、构建前端缓存对象
|
|
|
|
|
LoginUserVo loginUserVo = new LoginUserVo();
|
|
|
|
|
BeanUtils.copyProperties(wxUserMember, loginUserVo);
|
|
|
|
|
loginUserVo.setToken(loginUser.getToken());
|
|
|
|
|
return loginUserVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|