use of com.ruoyi.common.core.domain.AjaxResult in project wumei-smart by kerwincui.
the class SysMenuController method roleMenuTreeselect.
/**
* 加载对应角色菜单列表树
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
List<SysMenu> menus = menuService.selectMenuList(getUserId());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
return ajax;
}
use of com.ruoyi.common.core.domain.AjaxResult 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.common.core.domain.AjaxResult 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.common.core.domain.AjaxResult 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);
}
use of com.ruoyi.common.core.domain.AjaxResult in project RuoYi-Vue by yangzongzhuan.
the class SysUserController method authRole.
/**
* 根据用户编号获取授权角色
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId) {
AjaxResult ajax = AjaxResult.success();
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
ajax.put("user", user);
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
return ajax;
}
Aggregations