From d86a4a8cd8cf271514e892e992290b4d533a24e5 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 12 一月 2024 14:32:49 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java | 44 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
index ebe2415..1a41c18 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
@@ -1,6 +1,9 @@
package com.dy.pipIrrBase.user;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoBa.BaUserMapper;
import com.dy.pipIrrGlobal.daoBa.BaUserRoleMapper;
@@ -13,9 +16,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
+import java.util.*;
@Slf4j
@Service
@@ -168,7 +169,40 @@
* @param userId 鐢ㄦ埛缂栧彿
* @return 鐢ㄦ埛淇℃伅鍒楄〃
*/
- public List<VoUserInfo> getUserInfos(Long userId) {
- return dao.getUserInfos(userId);
+ public VoUserInfo getUserInfos(Long userId) {
+ VoUserInfo voUserInfo = new VoUserInfo();
+ String permission = "";
+ Map map = Optional.ofNullable(dao.getUserInfoById(userId)).orElse(new HashMap());
+ if(map.size() > 0) {
+ voUserInfo.setUserId(userId);
+ voUserInfo.setUserName(map.get("userName").toString());
+ }
+
+ List list_roleIds = new ArrayList();
+ List list_roleNames = new ArrayList();
+ List list_permissions = new ArrayList();
+
+ List<Map<String, Object>> list = Optional.ofNullable(urDao.getPermissionsByUserId(userId)).orElse(new ArrayList<>());
+ if(list.size() > 0) {
+ JSONArray array= JSONArray.parseArray(JSON.toJSONString(list));
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject job = array.getJSONObject(i);
+ list_roleIds.add(job.getLong("roleId"));
+ list_roleNames.add(job.getString("roleName"));
+
+ String permissions = Optional.ofNullable(job.getString("permissions")).orElse("");
+ if(permissions.length() > 0) {
+ permissions = permissions.substring(1, permissions.length() - 1);
+ permissions= permissions.replace(String.valueOf(" "), "");
+ permission = permission + permissions + ",";
+ }
+ }
+ voUserInfo.setRoleIds(list_roleIds);
+ voUserInfo.setRoleNames(list_roleNames);
+ permission = permission.substring(0, permission.length()-1);
+ list_permissions.add(permission);
+ voUserInfo.setPermissions(list_permissions);
+ }
+ return voUserInfo;
}
}
--
Gitblit v1.8.0