Browse Source

feat: 大屏对接沃运维

weijianghai 2 years ago
parent
commit
8135ec4878

+ 6 - 0
pom.xml

@@ -46,6 +46,12 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
+        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.10</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>

+ 5 - 1
src/main/java/com/nokia/service/AclService.java

@@ -27,16 +27,18 @@ public class AclService {
     private final UserDao userDao;
     private final TopService topService;
     private final DopService dopService;
+    private final WoyunweiService woyunweiService;
 
     private final RedisTemplate<String, Object> redisTemplate;
     private final VerificationLogDao verificationLogDao;
 
     @Autowired
-    public AclService(UserDao userDao, TopService topService, DopService dopService,
+    public AclService(UserDao userDao, TopService topService, DopService dopService, WoyunweiService woyunweiService,
                       RedisTemplate<String, Object> redisTemplate, VerificationLogDao verificationLogDao) {
         this.userDao = userDao;
         this.topService = topService;
         this.dopService = dopService;
+        this.woyunweiService = woyunweiService;
         this.redisTemplate = redisTemplate;
         this.verificationLogDao = verificationLogDao;
     }
@@ -98,6 +100,8 @@ public class AclService {
             return dopService.dopReturn(token);
         } else if (fromSystem.trim().equalsIgnoreCase("top")) {
             return topService.topReturn(token);
+        } else if (fromSystem.trim().equalsIgnoreCase("woyunwei")) {
+            return woyunweiService.woyunweiReturn(token);
         } else if (fromSystem.trim().equalsIgnoreCase("test")) {
             // 测试用
             return testToken(token);

+ 26 - 0
src/main/java/com/nokia/service/WoyunweiService.java

@@ -0,0 +1,26 @@
+package com.nokia.service;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.nokia.vo.TokenFlagVo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+
+@Slf4j
+@Service
+public class WoyunweiService {
+    public TokenFlagVo woyunweiReturn(String token) {
+        String url = "https://10.170.43.39:8038/PAOOS/aaaa/userservice/getUserInfo.do?method=findUserBySessionID&sessionID=" + token;
+        RestTemplate restTemplate = new RestTemplate();
+        String r = restTemplate.postForObject(url, new Object(), String.class);
+        log.info("沃运维获取用户信息响应: {}", r);
+        JsonObject jsonObject = JsonParser.parseString(r).getAsJsonObject();
+        String userName = jsonObject.get("userName").getAsString();
+        TokenFlagVo vo = new TokenFlagVo();
+        vo.setIsValid(StringUtils.hasText(userName) ? 0 : 1);
+        vo.setLoginName(userName);
+        return vo;
+    }
+}