Browse Source

20220805 v1.9 修改了无权限时的bug

lifuquan 2 years ago
parent
commit
c5fd5b32fd

+ 1 - 1
doc/接口文档/acl提供给黑点库的接口.md

@@ -16,7 +16,7 @@ POST http://127.0.0.1:12128/api/verification
 Content-Type: application/json
 
 {
-  "token": "test_token_abc",
+  "token": "test_token_hengshui",
   "fromSystem": "test",
   "system": "heidianku"
 }

BIN
doc/部署文档/正式环境/bin/aclTousu.jar


+ 5 - 5
doc/部署文档/正式环境/正式环境版本更新文档.md

@@ -61,7 +61,7 @@ POST http://133.96.94.176:12128/api/verification
 Content-Type: application/json
 
 {
-  "token": "test_token_hebei",
+  "token": "test_token_hengshui",
   "fromSystem": "test",
   "system": "heidianku"
 }
@@ -74,7 +74,7 @@ POST http://133.96.94.176:12128/api/verification
 Content-Type: application/json
 
 {
-  "token": "test_token_abc",
+  "token": "test_token_hengshui2",
   "fromSystem": "test",
   "system": "liucheng"
 }
@@ -87,7 +87,7 @@ POST http://133.96.94.176:12128/api/verification
 Content-Type: application/json
 
 {
-  "token": "test_token_abc",
+  "token": "test_token_hengshui",
   "fromSystem": "test",
   "system": "daping"
 }
@@ -100,7 +100,7 @@ POST http://133.96.94.176:12128/api/verification
 Content-Type: application/json
 
 {
-  "token": "test_token_abc",
+  "token": "test_token_hengshui",
   "fromSystem": "test",
   "system": "fenxi"
 }
@@ -113,7 +113,7 @@ POST http://133.96.94.176:12128/api/verification
 Content-Type: application/json
 
 {
-"token": "test_token_abc",
+"token": "test_token_hengshui",
 "fromSystem": "test",
 "system": "yuce"
 }

BIN
doc/部署文档/测试环境/bin/aclTousu.jar


+ 40 - 23
src/main/java/com/nokia/controller/VerificationController.java

@@ -39,40 +39,57 @@ public class VerificationController {
         log.debug("输入参数: {}", tokenEntity);
         User userEntity = aclService.verifySystem(tokenEntity.getToken(), tokenEntity.getFromSystem());
         log.debug("输出用户信息: {}", userEntity);
-        if (userEntity == null) {
-            Map<String, String> map = new HashMap<>();
-            if (tokenEntity.getFromSystem().equalsIgnoreCase("top")) {
-                map.put("redirect", topRedirectUrl);
-            } else if (tokenEntity.getFromSystem().equalsIgnoreCase("dop")) {
-                map.put("redirect", dopRedirectUrl);
-            } else {
-                switch (tokenEntity.getSystem().trim().toLowerCase()) {
-                    case "daping":
-                        map.put("redirect", dopRedirectUrl);
-                        break;
-                    case "liucheng":
-                    case "fenxi":
-                    case "yuce":
-                    default:
-                        map.put("redirect", topRedirectUrl);
-                        break;
-                }
+        Map<String, String> map = new HashMap<>();
+        if (tokenEntity.getFromSystem().equalsIgnoreCase("top")) {
+            map.put("redirect", topRedirectUrl);
+        } else if (tokenEntity.getFromSystem().equalsIgnoreCase("dop")) {
+            map.put("redirect", dopRedirectUrl);
+        } else {
+            switch (tokenEntity.getSystem().trim().toLowerCase()) {
+                case "daping":
+                    map.put("redirect", dopRedirectUrl);
+                    break;
+                case "liucheng":
+                case "fenxi":
+                case "yuce":
+                case "heidianku":
+                default:
+                    map.put("redirect", topRedirectUrl);
+                    break;
             }
+        }
+        if (userEntity == null) {
             return R.error().data(map).message("用户不存在");
         } else {
             switch (tokenEntity.getSystem().trim().toLowerCase()) {
                 case "liucheng":
                     return R.ok().data(new LiuchengUserVo(userEntity));
                 case "fenxi":
-                    return R.ok().data(new FenxiUserVo(userEntity));
+                    FenxiUserVo fenxiUserVo = new FenxiUserVo(userEntity);
+                    if (fenxiUserVo.getCity() == null) {
+                        return R.error().data(map).message("用户不存在");
+                    }
+                    return R.ok().data(fenxiUserVo);
                 case "daping":
-                    return R.ok().data(new DapingUserVo(userEntity));
+                    DapingUserVo dapingUserVo = new DapingUserVo(userEntity);
+                    if (dapingUserVo.getCity() == null) {
+                        return R.error().data(map).message("用户不存在");
+                    }
+                    return R.ok().data(dapingUserVo);
                 case "yuce":
-                    return R.ok().data(new YuceUserVo(userEntity));
+                    YuceUserVo yuceUserVo = new YuceUserVo(userEntity);
+                    if (yuceUserVo.getCity() == null) {
+                        return R.error().data(map).message("用户不存在");
+                    }
+                    return R.ok().data(yuceUserVo);
                 case "heidianku":
-                    return R.ok().data(new HeidiankuUserVo(userEntity));
+                    HeidiankuUserVo heidiankuUserVo = new HeidiankuUserVo(userEntity);
+                    if (heidiankuUserVo.getCity() == null) {
+                        return R.error().data(map).message("用户不存在");
+                    }
+                    return R.ok().data(heidiankuUserVo);
                 default:
-                    return R.error().message("当前允许的system为:liucheng/fenxi/daping/yuce");
+                    return R.error().message("当前允许的system为: liucheng/fenxi/daping/yuce/heidianku");
             }
         }
     }

+ 9 - 0
src/test/java/com/nokia/service/UserServiceTest.java

@@ -7,6 +7,7 @@ import java.io.IOException;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.RedisTemplate;
 
 import com.nokia.pojo.User;
 import com.nokia.pojo.UserRoleCity;
@@ -14,9 +15,17 @@ import com.nokia.pojo.UserRoleCity;
 @SpringBootTest
 public class UserServiceTest {
 
+    @Autowired
+    private RedisTemplate redisTemplate;
+
     @Autowired
     private UserService userService;
 
+    @Test
+    void cleanRedis() {
+        redisTemplate.delete("test_token_baoding");
+    }
+
     @Test
     void testGetByLoginName() {
         User user = userService.getByLoginName("test_abc");