Selaa lähdekoodia

不同用户登录之后,点击可视化时,查看该用户下的装置

丁治程 7 kuukautta sitten
vanhempi
commit
0eb08bd693

+ 41 - 10
jeecg-module-interlock/src/main/java/org/jeecg/modules/dashboardInterface/controller/InterlockDeviceController.java

@@ -3,14 +3,21 @@ package org.jeecg.modules.dashboardInterface.controller;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.client.HttpClient;
+import org.apache.tomcat.util.net.openssl.ciphers.Authentication;
+import org.jeecg.common.util.SpringContextUtils;
 import org.jeecg.modules.base.mapper.InterlockBaseMapper;
 import org.jeecg.modules.dashboardInterface.service.IDashboardINterfaceService;
 import org.jeecg.modules.interlockUser.entity.InterlockUser;
 import org.jeecg.modules.iotedgeCollectData.entity.ResultD;
 import org.jeecg.modules.iotedgeCollectData.service.RestClientService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.*;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
 
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -43,6 +50,10 @@ public class InterlockDeviceController {
     @SuppressWarnings("all")
     private InterlockBaseMapper baseMapper;
 
+    @Autowired
+    @SuppressWarnings("all")
+    private RestTemplate restTemplate;
+
     @GetMapping(value = "/")
     public JSONObject testConnect() {
         log.info("检查服务成功");
@@ -52,23 +63,43 @@ public class InterlockDeviceController {
     }
 
     @PostMapping(value = "/search")
-    public String search(@RequestBody JSONObject request) {
+    public String search(@RequestBody JSONObject request,HttpServletRequest httpServletRequest) {
         log.info("调用search接口:{}", JSON.toJSONString(request));
-        //List<String> list = new ArrayList<>();
+
+        String eiToken = "";
+        String wisEUser = "";
+
+        Cookie[] cookies = httpServletRequest.getCookies();
+
+        if (cookies != null) {
+            for (Cookie cookie : cookies) {
+                if (cookie.getName().equals("EIToken")) {
+                    eiToken = cookie.getValue();
+                }
+                if (cookie.getName().equals("WISEUser")) {
+                    wisEUser = cookie.getValue();
+                }
+            }
+        }
+
+
+
         //List<String> ssoLoginInfo = restClientService.getSSOLoginInfo();
         //String wiSEUser = ssoLoginInfo.stream()
         //        .filter(s -> s.startsWith("WISEUser="))
         //        .map(s -> s.substring("WISEUser=".length()).split(";")[0].trim())
         //        .findFirst()
         //        .orElse("WiSEUser not found");
-        //
-        //InterlockUser interlockUser = baseMapper.getUserInfoByName(wiSEUser);
-        //if(interlockUser.getRole().equals("0")){//如果当前用户是系统管理员
-        //    list = dashboardService.getAllDevice();
-        //}else{
-        //    list = dashboardService.getDeviceByUser(wiSEUser);
-        //}
-        List<String> list = dashboardService.getAllDevice();
+
+        List<String> list = new ArrayList<>();
+        InterlockUser interlockUser = baseMapper.getUserInfoByName(wisEUser);
+        if(interlockUser.getRole().equals("0")){//如果当前用户是系统管理员
+            list = dashboardService.getAllDevice();
+        }else{
+            list = dashboardService.getDeviceByUser(wisEUser);
+        }
+
+        //List<String> list = dashboardService.getAllDevice();
 
         return JSON.toJSONString(list);
     }