use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.
the class UserSocialProfileServiceImpl method bindUser.
@Override
public AjaxResult bindUser(String bindId, Long sysUserId) {
BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindId);
if (bindValue == null) {
// 不作提示
return AjaxResult.error(HttpStatus.NO_MESSAGE_ALERT, "未知异常");
}
SocialUser socialUser = findSocialUser(bindValue.getUuid(), bindValue.getSource());
SocialUser updateSocialUser = new SocialUser();
updateSocialUser.setSocialUserId(socialUser.getSocialUserId());
updateSocialUser.setSysUserId(sysUserId);
iSocialUserService.updateSocialUser(updateSocialUser);
redisCache.deleteObject(BIND_REDIS_KEY + bindId);
return AjaxResult.success("绑定成功!");
}
use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.
the class SocialLoginServiceImpl method genBindId.
private String genBindId(AuthUser authUser) {
String bindId = Md5Utils.hash(authUser.getUuid() + authUser.getSource());
String key = BIND_REDIS_KEY + bindId;
BindIdValue bindIdValue = new BindIdValue();
bindIdValue.setSource(authUser.getSource());
bindIdValue.setUuid(authUser.getUuid());
redisCache.setCacheObject(key, bindIdValue, BIND_EXPIRE_TIME, TimeUnit.SECONDS);
return bindId;
}
use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.
the class SocialLoginServiceImpl method bindLogin.
@Override
public AjaxResult bindLogin(BindLoginBody bindLoginBody) {
BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindLoginBody.getBindId());
SocialUser socialUser = findSocialUser(bindValue.getUuid(), bindValue.getSource());
AjaxResult checkAjax = checkSocialUser(socialUser, bindLoginBody.getBindId());
if (checkAjax != null) {
return checkAjax;
}
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = sysLoginService.login(bindLoginBody.getUsername(), bindLoginBody.getPassword(), bindLoginBody.getCode(), bindLoginBody.getUuid());
LoginUser loginUser = tokenService.getLoginUserByToken(token);
// 绑定和更新
SocialUser updateSocialUser = new SocialUser();
updateSocialUser.setSysUserId(loginUser.getUserId());
updateSocialUser.setSocialUserId(socialUser.getSocialUserId());
iSocialUserService.updateSocialUser(updateSocialUser);
ajax.put(Constants.TOKEN, token);
redisCache.deleteObject(BIND_REDIS_KEY + bindLoginBody.getBindId());
return ajax;
}
use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.
the class SocialLoginServiceImpl method checkBindId.
@Override
public AjaxResult checkBindId(String bindId) {
AjaxResult ajax = AjaxResult.success();
ajax.put("bindAccount", false);
if (StringUtils.isEmpty(bindId)) {
return ajax;
}
BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindId);
if (bindValue == null) {
return ajax;
}
ajax.put("bindAccount", true);
return AjaxResult.success(bindId);
}
use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.
the class SocialLoginServiceImpl method bindRegister.
@Override
public AjaxResult bindRegister(BindRegisterBody bindRegisterBody) {
if (!("true".equals(iSysConfigService.selectConfigByKey("sys.account.registerUser")))) {
return error("当前系统没有开启注册功能!");
}
BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindRegisterBody.getBindId());
SocialUser socialUser = findSocialUser(bindValue.getUuid(), bindValue.getSource());
AjaxResult checkAjax = checkSocialUser(socialUser, bindRegisterBody.getBindId());
if (checkAjax != null) {
return checkAjax;
}
AjaxResult ajax = AjaxResult.success();
String msg = sysRegisterService.register(bindRegisterBody);
if (StringUtils.isEmpty(msg)) {
SysUser sysUser = iSysUserService.selectUserByUserName(bindRegisterBody.getUsername());
// 绑定和更新
SocialUser updateSocialUser = new SocialUser();
updateSocialUser.setSysUserId(sysUser.getUserId());
updateSocialUser.setSocialUserId(socialUser.getSocialUserId());
iSocialUserService.updateSocialUser(updateSocialUser);
redisCache.deleteObject(BIND_REDIS_KEY + bindRegisterBody.getBindId());
}
return StringUtils.isEmpty(msg) ? ajax : error(msg);
}
Aggregations