Browse Source

作者:张哲
时间:2023/01/18
类型:开发
描述:里程碑(2) 获取当前登陆人信息

ZizgZh 2 years ago
parent
commit
0249e55244

+ 6 - 0
src/main/java/com/redxun/knowledge/common/UserService.java

@@ -4,6 +4,7 @@ import com.redxun.common.model.JPaasUser;
 import com.redxun.common.tool.StringUtils;
 import com.redxun.common.utils.ExceptionUtil;
 import com.redxun.common.utils.SysUserUtil;
+import com.redxun.dto.user.OsGroupDto;
 import com.redxun.dto.user.OsUserDto;
 import com.redxun.feign.org.OrgClient;
 import com.redxun.feign.org.UserClient;
@@ -151,5 +152,10 @@ public class UserService {
         return osUserDtoList;
     }
 
+    public OsGroupDto getCompanyById(String companyId){
+        OsGroupDto osGroupDto = orgClient.getCompanyById(companyId);
+        return osGroupDto;
+    }
+
 
 }

+ 10 - 0
src/main/java/com/redxun/knowledge/controller/CommonController.java

@@ -3,6 +3,7 @@ package com.redxun.knowledge.controller;
 import com.redxun.common.annotation.ClassDefine;
 import com.redxun.common.base.db.BaseService;
 import com.redxun.common.base.entity.JsonResult;
+import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.entity.dao.CommonEntity;
 import com.redxun.knowledge.entity.vo.DicVo;
 import com.redxun.knowledge.entity.vo.PositionSequenceVo;
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 系统内容相关
@@ -71,4 +73,12 @@ public class CommonController extends BaseController<CommonEntity> {
         return jsonResult;
     }
 
+    @ApiOperation("获取当前登陆人信息")
+    @GetMapping("loginUserInfo")
+    public JsonResult loginUserInfo(){
+        JsonResult jsonResult = JsonResult.getSuccessResult("");
+        Map<String,Object> result = systemService.loginUserInfo();
+        return jsonResult.setData(result);
+    }
+
 }

+ 28 - 0
src/main/java/com/redxun/knowledge/service/CommonServiceImpl.java

@@ -5,17 +5,22 @@ import com.redxun.common.base.db.BaseDao;
 import com.redxun.common.base.db.BaseService;
 import com.redxun.common.service.impl.SuperServiceImpl;
 import com.redxun.datasource.DataSourceContextHolder;
+import com.redxun.dto.user.OsUserDto;
 import com.redxun.feign.sys.SystemClient;
+import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.entity.dao.CommonEntity;
 import com.redxun.knowledge.entity.vo.DicVo;
 import com.redxun.knowledge.entity.vo.PositionSequenceVo;
 import com.redxun.knowledge.mapper.CommonMapper;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 业务系统相关服务类
@@ -27,6 +32,9 @@ public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEnti
     @Resource
     private CommonMapper commonMapper;
 
+    @Autowired
+    private UserService userService;
+
     @Resource
     @Lazy
     SystemClient systemClient;
@@ -59,8 +67,28 @@ public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEnti
         return result;
     }
 
+    /**
+     * 获取字典数据(知识地图类型)
+     * @param alias
+     * @return
+     */
     public List<DicVo> queryDic(String alias) {
         List<DicVo> result = commonMapper.queryDic(alias);
         return result;
     }
+
+    /**
+     * 获取当前登录用户信息
+     * @return
+     */
+    public Map<String, Object> loginUserInfo() {
+        String userId = userService.queryLoginUser();
+        OsUserDto osUserDto = userService.queryOsUserDto(userId);
+        Map<String, Object> map = new HashMap<>();
+        map.put("userId",userId);
+        map.put("name",osUserDto.getFullName());
+        // map.put("companyName",userService.getCompanyById(osUserDto.getCompanyId()).getName());
+        map.put("deptName",osUserDto.getDeptName());
+        return map;
+    }
 }