| | |
| | | package com.ruoyi.framework.security.service;
|
| | |
|
| | | import com.ruoyi.project.system.mapper.SysDeptMapper;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.core.Authentication;
|
| | | import org.springframework.security.core.context.SecurityContextHolder;
|
| | | import org.springframework.security.core.userdetails.UserDetails;
|
| | | import org.springframework.security.core.userdetails.UserDetailsService;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.enums.UserStatus;
|
| | | import com.ruoyi.common.exception.ServiceException;
|
| | | import com.ruoyi.common.utils.MessageUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.mapper.SysDeptMapper;
|
| | | import com.ruoyi.project.system.service.ISysUserService;
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.security.core.Authentication;
|
| | | import org.springframework.security.core.context.SecurityContextHolder;
|
| | | import org.springframework.security.core.userdetails.UserDetails;
|
| | | import org.springframework.security.core.userdetails.UserDetailsService;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | * @author ruoyi
|
| | | */
|
| | | @Service
|
| | | @RequiredArgsConstructor
|
| | | public class UserDetailsServiceImpl implements UserDetailsService
|
| | | {
|
| | | private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class);
|
| | |
|
| | | @Autowired
|
| | | private ISysUserService userService;
|
| | | |
| | | @Autowired
|
| | | private SysPasswordService passwordService;
|
| | |
|
| | | @Autowired
|
| | | private SysPermissionService permissionService;
|
| | |
|
| | | @Autowired
|
| | | private SysDeptMapper deptMapper;
|
| | | private final ISysUserService userService;
|
| | | private final SysPasswordService passwordService;
|
| | | private final SysPermissionService permissionService;
|
| | | private final SysDeptMapper deptMapper;
|
| | |
|
| | | @Override
|
| | | public UserDetails loadUserByUsername(String username)
|
| | |
| | | // 查询租户
|
| | | Long teantId = deptMapper.maxLevelDeptId(factoryId);
|
| | | user.setCurrentDeptId(factoryId);
|
| | | user.setTenantId(teantId.intValue());
|
| | | user.setTenantId(teantId);
|
| | | }
|
| | | }
|
| | | // 获取用户当前登录部门,并查询租户id
|