From 5cd51759d8397580d379bd0dc405ef1886b580f0 Mon Sep 17 00:00:00 2001 From: fengjunfeng Date: Mon, 24 Jan 2022 10:39:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=9D=A5=E6=BA=90=E6=9C=89?= =?UTF-8?q?=E6=95=88=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../license/controller/LicenseController.java | 33 +++++++++---------- .../license/LicenseApplicationTests.java | 13 -------- 2 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 src/test/java/com/sentinel/license/LicenseApplicationTests.java diff --git a/src/main/java/com/license/controller/LicenseController.java b/src/main/java/com/license/controller/LicenseController.java index 01b3f71..24c9cd8 100644 --- a/src/main/java/com/license/controller/LicenseController.java +++ b/src/main/java/com/license/controller/LicenseController.java @@ -41,9 +41,9 @@ public class LicenseController { */ @PostMapping("/licenseOperation") public Object licenseOperation(@RequestBody LicenseInfo licenseInfo) { -// if (!verify(licenseInfo.getServerId())){ -// return null; -// } + if (!verify(licenseInfo.getServerId())){ + return null; + } if (licenseInfo.getType().equals(Constant.LICENSE_C2V)){ //获取C2V信息 return HaspUtil.readC2V(licenseInfo.getVendorCode(),licenseInfo.getFeatureId()); @@ -77,9 +77,8 @@ public class LicenseController { headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); HttpEntity httpEntity = new HttpEntity<>(null, headers); String url = "http://" + GetIpProtUtil.getLocalIP() +":" + port + "/getServerId"; - ResponseEntity entity = restTemplate.exchange(url, HttpMethod.GET,httpEntity,Map.class); - log.info("license status: {}", JSONUtil.toJsonStr(entity)); - String str = MapUtil.get(entity.getBody(), "data", String.class); + String str = restTemplate.exchange(url, HttpMethod.GET,httpEntity,String.class).getBody(); + log.info("license bifang_api server id: {}", str); if (str.equals(serverId)){ return true; } @@ -90,16 +89,16 @@ public class LicenseController { } - @PostMapping("/test") - public Object test() { - verify("1111"); - - if (CacheManager.getCache("test") == null){ - CacheManager.addCache("test","11111"); - }else { - System.out.println(CacheManager.getCache("test")); - } - return null; - } +// @PostMapping("/test") +// public Object test() { +// verify("1111"); +// +// if (CacheManager.getCache("test") == null){ +// CacheManager.addCache("test","11111"); +// }else { +// System.out.println(CacheManager.getCache("test")); +// } +// return null; +// } } diff --git a/src/test/java/com/sentinel/license/LicenseApplicationTests.java b/src/test/java/com/sentinel/license/LicenseApplicationTests.java deleted file mode 100644 index 8f7f818..0000000 --- a/src/test/java/com/sentinel/license/LicenseApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.sentinel.license; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class LicenseApplicationTests { - - @Test - void contextLoads() { - } - -}