yaowanxin
2025-08-11 1b5604f8a88000e2f51d4c989fd179989468ee67
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;
    /**
     * 登录方法
     * 
@@ -64,11 +73,20 @@
     * 
     * @return 用户信息
     */
    @GetMapping("getInfo")
    @GetMapping("/getInfo")
    public AjaxResult getInfo()
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = loginUser.getUser();
        // 获取当前登录公司
        Long 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);
    }
    /**