Search in sources :

Example 41 with AjaxResult

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;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysMenu(com.ruoyi.common.core.domain.entity.SysMenu) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 42 with AjaxResult

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;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SocialUser(com.ruoyi.iot.domain.SocialUser) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) BindIdValue(com.ruoyi.iot.model.login.BindIdValue)

Example 43 with AjaxResult

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);
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) BindIdValue(com.ruoyi.iot.model.login.BindIdValue)

Example 44 with AjaxResult

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);
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) SocialUser(com.ruoyi.iot.domain.SocialUser) BindIdValue(com.ruoyi.iot.model.login.BindIdValue)

Example 45 with AjaxResult

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;
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) SysUser(com.ruoyi.common.core.domain.entity.SysUser) TableDataInfo(com.ruoyi.common.core.page.TableDataInfo) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ArrayUtils(org.apache.commons.lang3.ArrayUtils) AjaxResult(com.ruoyi.common.core.domain.AjaxResult) RequestBody(org.springframework.web.bind.annotation.RequestBody) StringUtils(com.ruoyi.common.utils.StringUtils) PutMapping(org.springframework.web.bind.annotation.PutMapping) SecurityUtils(com.ruoyi.common.utils.SecurityUtils) ISysRoleService(com.ruoyi.system.service.ISysRoleService) GetMapping(org.springframework.web.bind.annotation.GetMapping) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) BaseController(com.ruoyi.common.core.controller.BaseController) PostMapping(org.springframework.web.bind.annotation.PostMapping) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) BusinessType(com.ruoyi.common.enums.BusinessType) List(java.util.List) ISysUserService(com.ruoyi.system.service.ISysUserService) UserConstants(com.ruoyi.common.constant.UserConstants) Log(com.ruoyi.common.annotation.Log) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) MultipartFile(org.springframework.web.multipart.MultipartFile) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ISysPostService(com.ruoyi.system.service.ISysPostService) AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) SysRole(com.ruoyi.common.core.domain.entity.SysRole) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

AjaxResult (com.ruoyi.common.core.domain.AjaxResult)55 GetMapping (org.springframework.web.bind.annotation.GetMapping)25 PostMapping (org.springframework.web.bind.annotation.PostMapping)16 SysUser (com.ruoyi.common.core.domain.entity.SysUser)12 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)10 Log (com.ruoyi.common.annotation.Log)8 StringUtils (com.ruoyi.common.utils.StringUtils)7 List (java.util.List)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 RestController (org.springframework.web.bind.annotation.RestController)7 MultipartFile (org.springframework.web.multipart.MultipartFile)7 SysUser (com.ruoyi.system.domain.SysUser)6 UserConstants (com.ruoyi.common.constant.UserConstants)5 BaseController (com.ruoyi.common.core.controller.BaseController)5 SysRole (com.ruoyi.common.core.domain.entity.SysRole)5 TableDataInfo (com.ruoyi.common.core.page.TableDataInfo)5 BusinessType (com.ruoyi.common.enums.BusinessType)5 SecurityUtils (com.ruoyi.common.utils.SecurityUtils)5