chenrui
4 天以前 d241b67a5728d4f2bb0d33e4921229a4bf15e250
src/main/java/com/ruoyi/project/system/controller/SysLoginController.java
@@ -1,11 +1,17 @@
package com.ruoyi.project.system.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.domain.vo.SysUserDeptVo;
import com.ruoyi.project.system.mapper.SysDeptMapper;
import com.ruoyi.project.system.service.ISysUserDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.SecurityUtils;
@@ -42,6 +48,9 @@
    @Autowired
    private ISysUserDeptService userDeptService;
    @Autowired
    private SysDeptMapper sysDeptMapper;
    /**
     * 登录方法
     * 
@@ -69,6 +78,15 @@
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = loginUser.getUser();
        // 获取当前登录公司
        Integer tenantId = loginUser.getTenantId();
        if(null != tenantId){
            user.setTenantId(tenantId);
            SysDept sysDept = sysDeptMapper.selectDeptById(tenantId.longValue());
            if(!ObjectUtils.isEmpty(sysDept)){
                user.setCurrentFactoryName(sysDept.getDeptName());
            }
        }
        // 角色集合
        Set<String> roles = permissionService.getRolePermission(user);
        // 权限集合
@@ -109,9 +127,17 @@
        }
    }
    @GetMapping("/userDeptList")
    public AjaxResult userDeptList(SysUserDeptVo sysUserDeptVo){
        return AjaxResult.success(userDeptService.selectUserDeptList(sysUserDeptVo));
    @GetMapping("/userLoginFacotryList")
    public AjaxResult userLoginFacotryList(SysUserDeptVo sysUserDeptVo){
        List<SysUserDeptVo> sysUserDeptVoList = userDeptService.userLoginFacotryList(sysUserDeptVo);
        Map<Long, SysUserDeptVo> map = sysUserDeptVoList.stream()
            .collect(Collectors.toMap(
                    SysUserDeptVo::getDeptId,
                    item -> item,
                    (existing, replacement) -> existing // 如果重复,保留第一个
            ));
        List<SysUserDeptVo> uniqueList = new ArrayList<>(map.values());
        return AjaxResult.success(uniqueList);
    }
    /**