update [重磅更新] 登录流程升级 支持缓存
This commit is contained in:
parent
5a271b8fde
commit
e763381186
@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.domain.vo.RouterVo;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
@ -99,7 +100,7 @@ public class SysLoginController {
|
||||
@ApiOperation("获取路由信息")
|
||||
@GetMapping("getRouters")
|
||||
public AjaxResult<List<RouterVo>> getRouters() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long userId = LoginUtils.getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
return AjaxResult.success(menuService.buildMenus(menus));
|
||||
}
|
||||
|
@ -113,10 +113,9 @@ public class SysProfileController extends BaseController {
|
||||
public AjaxResult<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) {
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
if (!file.isEmpty()) {
|
||||
SysUser user = SecurityUtils.getUser();
|
||||
SysOss oss = iSysOssService.upload(file);
|
||||
String avatar = oss.getUrl();
|
||||
if (userService.updateUserAvatar(user.getUserName(), avatar)) {
|
||||
if (userService.updateUserAvatar(getUsername(), avatar)) {
|
||||
ajax.put("imgUrl", avatar);
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.ruoyi.common.core.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
@ -70,28 +70,28 @@ public class BaseController {
|
||||
/**
|
||||
* 获取用户缓存信息
|
||||
*/
|
||||
public SysUser getUser() {
|
||||
return SecurityUtils.getUser();
|
||||
public LoginUser getUser() {
|
||||
return LoginUtils.getLoginUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户id
|
||||
*/
|
||||
public Long getUserId() {
|
||||
return SecurityUtils.getUserId();
|
||||
return LoginUtils.getUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录部门id
|
||||
*/
|
||||
public Long getDeptId() {
|
||||
return SecurityUtils.getDeptId();
|
||||
return LoginUtils.getDeptId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户名
|
||||
*/
|
||||
public String getUsername() {
|
||||
return SecurityUtils.getUsername();
|
||||
return LoginUtils.getUsername();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,83 @@
|
||||
package com.ruoyi.common.core.domain.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 登录用户身份权限
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class LoginUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 用户唯一标识
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 登录时间
|
||||
*/
|
||||
private Long loginTime;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private Long expireTime;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 登录地点
|
||||
*/
|
||||
private String loginLocation;
|
||||
|
||||
/**
|
||||
* 浏览器类型
|
||||
*/
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 菜单权限
|
||||
*/
|
||||
private Set<String> menuPermission;
|
||||
|
||||
/**
|
||||
* 角色权限
|
||||
*/
|
||||
private Set<String> rolePermission;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
}
|
@ -10,7 +10,7 @@ import com.ruoyi.common.exception.base.BaseException;
|
||||
public class UserException extends BaseException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UserException(String code, Object[] args) {
|
||||
public UserException(String code, Object... args) {
|
||||
super("user", code, args, null);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.DeviceType;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.UtilException;
|
||||
@ -13,39 +15,68 @@ import com.ruoyi.common.exception.UtilException;
|
||||
*/
|
||||
public class LoginUtils {
|
||||
|
||||
private final static String LOGIN_USER_KEY = "loginUser";
|
||||
|
||||
/**
|
||||
* 登录系统
|
||||
* 针对两套用户体系
|
||||
* @param userId 用户id
|
||||
* @param loginUser 登录用户信息
|
||||
*/
|
||||
public static void login(Long userId, UserType userType) {
|
||||
StpUtil.login(userType.getUserType() + userId);
|
||||
public static void login(LoginUser loginUser, UserType userType) {
|
||||
StpUtil.login(userType.getUserType() + loginUser.getUserId());
|
||||
StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录系统 基于 设备类型
|
||||
* 针对一套用户体系
|
||||
* @param userId 用户id
|
||||
* @param loginUser 登录用户信息
|
||||
*/
|
||||
public static void loginByDevice(Long userId, UserType userType, DeviceType deviceType) {
|
||||
StpUtil.login(userType.getUserType() + userId, deviceType.getDevice());
|
||||
public static void loginByDevice(LoginUser loginUser, UserType userType, DeviceType deviceType) {
|
||||
StpUtil.login(userType.getUserType() + loginUser.getUserId(), deviceType.getDevice());
|
||||
StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
**/
|
||||
public static LoginUser getLoginUser() {
|
||||
return (LoginUser) StpUtil.getTokenSession().get(LOGIN_USER_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*/
|
||||
public static Long getUserId() {
|
||||
String loginId = StpUtil.getLoginIdAsString();
|
||||
String userId;
|
||||
String replace = "";
|
||||
if (StringUtils.contains(loginId, UserType.SYS_USER.getUserType())) {
|
||||
userId = StringUtils.replace(loginId, UserType.SYS_USER.getUserType(), replace);
|
||||
} else if (StringUtils.contains(loginId, UserType.APP_USER.getUserType())){
|
||||
userId = StringUtils.replace(loginId, UserType.APP_USER.getUserType(), replace);
|
||||
} else {
|
||||
throw new UtilException("登录用户: LoginId异常 => " + loginId);
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
String loginId = StpUtil.getLoginIdAsString();
|
||||
String userId;
|
||||
String replace = "";
|
||||
if (StringUtils.contains(loginId, UserType.SYS_USER.getUserType())) {
|
||||
userId = StringUtils.replace(loginId, UserType.SYS_USER.getUserType(), replace);
|
||||
} else if (StringUtils.contains(loginId, UserType.APP_USER.getUserType())){
|
||||
userId = StringUtils.replace(loginId, UserType.APP_USER.getUserType(), replace);
|
||||
} else {
|
||||
throw new UtilException("登录用户: LoginId异常 => " + loginId);
|
||||
}
|
||||
return Long.parseLong(userId);
|
||||
}
|
||||
return Long.parseLong(userId);
|
||||
return loginUser.getUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门ID
|
||||
**/
|
||||
public static Long getDeptId() {
|
||||
return getLoginUser().getDeptId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户账户
|
||||
**/
|
||||
public static String getUsername() {
|
||||
return getLoginUser().getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,41 +13,13 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
* @author Long Li
|
||||
*/
|
||||
public class SecurityUtils {
|
||||
/**
|
||||
* 用户ID
|
||||
**/
|
||||
public static Long getUserId() {
|
||||
return LoginUtils.getUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门ID
|
||||
**/
|
||||
public static Long getDeptId() {
|
||||
try {
|
||||
return getUser().getDeptId();
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("获取部门ID异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户账户
|
||||
**/
|
||||
public static String getUsername() {
|
||||
try {
|
||||
return getUser().getUserName();
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("获取用户账户异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
**/
|
||||
public static SysUser getUser() {
|
||||
try {
|
||||
return SpringUtils.getBean(UserService.class).selectUserById(getUserId());
|
||||
return SpringUtils.getBean(UserService.class).selectUserById(LoginUtils.getUserId());
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("获取用户信息异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
|
@ -2,12 +2,11 @@ package com.ruoyi.framework.aspectj;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.dto.OperLogDTO;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.service.OperLogService;
|
||||
import com.ruoyi.common.enums.BusinessStatus;
|
||||
import com.ruoyi.common.enums.HttpMethod;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
@ -60,9 +59,6 @@ public class LogAspect {
|
||||
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
|
||||
try {
|
||||
|
||||
// 获取当前的用户
|
||||
SysUser sysUser = SecurityUtils.getUser();
|
||||
|
||||
// *========数据库日志=========*//
|
||||
OperLogDTO operLog = new OperLogDTO();
|
||||
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
||||
@ -70,9 +66,7 @@ public class LogAspect {
|
||||
String ip = ServletUtils.getClientIP();
|
||||
operLog.setOperIp(ip);
|
||||
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
|
||||
if (sysUser != null) {
|
||||
operLog.setOperName(sysUser.getUserName());
|
||||
}
|
||||
operLog.setOperName(LoginUtils.getUsername());
|
||||
|
||||
if (e != null) {
|
||||
operLog.setStatus(BusinessStatus.FAIL.ordinal());
|
||||
|
@ -6,7 +6,7 @@ import cn.dev33.satoken.jwt.StpLogicJwtForStyle;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.config.properties.SecurityProperties;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -43,7 +43,7 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
||||
.notMatch(securityProperties.getExcludes())
|
||||
.check(() -> {
|
||||
if (log.isDebugEnabled()) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long userId = LoginUtils.getUserId();
|
||||
if (StringUtils.isNotNull(userId)) {
|
||||
log.debug("剩余有效时间: {}", StpUtil.getTokenTimeout());
|
||||
log.debug("临时有效时间: {}", StpUtil.getTokenActivityTimeout());
|
||||
|
@ -4,9 +4,9 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
@ -76,14 +76,14 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
||||
* 获取登录用户名
|
||||
*/
|
||||
private String getLoginUsername() {
|
||||
SysUser user;
|
||||
LoginUser user;
|
||||
try {
|
||||
user = SecurityUtils.getUser();
|
||||
user = LoginUtils.getLoginUser();
|
||||
} catch (Exception e) {
|
||||
log.warn("自动注入警告 => 用户未登录");
|
||||
return null;
|
||||
}
|
||||
return user.getUserName();
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.ruoyi.framework.dao;
|
||||
package com.ruoyi.framework.satoken.dao;
|
||||
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
@ -1,34 +1,23 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
package com.ruoyi.framework.satoken.service;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.system.service.SysPermissionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class SaInterfaceImpl implements StpInterface {
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService sysPermissionService;
|
||||
@Autowired
|
||||
private ISysUserService iSysUserService;
|
||||
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
UserType userType = LoginUtils.getUserType(loginId);
|
||||
if (userType == UserType.SYS_USER) {
|
||||
Long userId = LoginUtils.getUserId();
|
||||
SysUser user = iSysUserService.getById(userId);
|
||||
Set<String> menuPermission = sysPermissionService.getMenuPermission(user);
|
||||
return new ArrayList<>(menuPermission);
|
||||
LoginUser loginUser = LoginUtils.getLoginUser();
|
||||
return new ArrayList<>(loginUser.getMenuPermission());
|
||||
} else if (userType == UserType.APP_USER) {
|
||||
// app端权限返回 自行根据业务编写
|
||||
}
|
||||
@ -39,10 +28,8 @@ public class SaInterfaceImpl implements StpInterface {
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
UserType userType = LoginUtils.getUserType(loginId);
|
||||
if (userType == UserType.SYS_USER) {
|
||||
Long userId = LoginUtils.getUserId();
|
||||
SysUser user = iSysUserService.getById(userId);
|
||||
Set<String> rolePermission = sysPermissionService.getRolePermission(user);
|
||||
return new ArrayList<>(rolePermission);
|
||||
LoginUser loginUser = LoginUtils.getLoginUser();
|
||||
return new ArrayList<>(loginUser.getRolePermission());
|
||||
} else if (userType == UserType.APP_USER) {
|
||||
// app端权限返回 自行根据业务编写
|
||||
}
|
@ -9,10 +9,7 @@ import com.ruoyi.common.constant.GenConstants;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.*;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
@ -159,7 +156,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
||||
@Override
|
||||
@Transactional
|
||||
public void importGenTable(List<GenTable> tableList) {
|
||||
String operName = SecurityUtils.getUsername();
|
||||
String operName = LoginUtils.getUsername();
|
||||
try {
|
||||
for (GenTable table : tableList) {
|
||||
String tableName = table.getTableName();
|
||||
|
@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.excel.ExcelListener;
|
||||
import com.ruoyi.common.excel.ExcelResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
@ -43,7 +44,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
||||
this.password = SpringUtils.getBean(ISysConfigService.class)
|
||||
.selectConfigByKey("sys.user.initPassword");
|
||||
this.isUpdateSupport = isUpdateSupport;
|
||||
this.operName = SecurityUtils.getUsername();
|
||||
this.operName = LoginUtils.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package com.ruoyi.system.service;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.service.LogininforService;
|
||||
import com.ruoyi.common.enums.DeviceType;
|
||||
import com.ruoyi.common.enums.UserStatus;
|
||||
@ -14,7 +15,6 @@ import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ruoyi.common.utils.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -37,6 +37,9 @@ public class SysLoginService {
|
||||
@Autowired
|
||||
private LogininforService asyncService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
@ -68,11 +71,17 @@ public class SysLoginService {
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"), request);
|
||||
throw new UserPasswordNotMatchException();
|
||||
}
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setUserId(user.getUserId());
|
||||
loginUser.setDeptId(user.getDeptId());
|
||||
loginUser.setUsername(user.getUserName());
|
||||
loginUser.setMenuPermission(permissionService.getMenuPermission(user));
|
||||
loginUser.setRolePermission(permissionService.getRolePermission(user));
|
||||
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request);
|
||||
recordLoginInfo(user.getUserId(), username);
|
||||
// 生成token
|
||||
LoginUtils.loginByDevice(user.getUserId(), UserType.SYS_USER, DeviceType.PC);
|
||||
LoginUtils.loginByDevice(loginUser, UserType.SYS_USER, DeviceType.PC);
|
||||
return StpUtil.getTokenValue();
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.TreeBuildUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
@ -154,7 +154,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public void checkDeptDataScope(Long deptId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
SysDept dept = new SysDept();
|
||||
dept.setDeptId(deptId);
|
||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
|
@ -8,8 +8,8 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.system.domain.SysRoleDept;
|
||||
@ -187,7 +187,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleDataScope(Long roleId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
SysRole role = new SysRole();
|
||||
role.setRoleId(roleId);
|
||||
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||
|
@ -10,6 +10,7 @@ import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.service.UserService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@ -225,7 +226,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
*/
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||
|
Loading…
x
Reference in New Issue
Block a user