diff --git a/src/main/resources/application.yml b/config/application.yml similarity index 99% rename from src/main/resources/application.yml rename to config/application.yml index 56d0ad9..59d212c 100644 --- a/src/main/resources/application.yml +++ b/config/application.yml @@ -13,8 +13,6 @@ logging: tsg: system: url: http://192.168.44.3:80 - username: - password: token: aa2bdec5518ad131f71944b13ce5c298&1& httpTimeout: 3600000 object: diff --git a/src/main/java/com/geedge/common/util/TsgUtil.java b/src/main/java/com/geedge/common/util/TsgUtil.java index 35663d6..ac0d11b 100644 --- a/src/main/java/com/geedge/common/util/TsgUtil.java +++ b/src/main/java/com/geedge/common/util/TsgUtil.java @@ -26,8 +26,6 @@ import java.util.concurrent.TimeUnit; public class TsgUtil { public static String TSG_URL; - private static String TSG_USERNAME; - private static String TSG_PASSWORD; private static Integer httpTimeOut; private static String TSG_TOKEN; @@ -41,16 +39,6 @@ public class TsgUtil { TSG_URL = url; } - @Value("${tsg.system.username}") - private void setTsgUsername(String username) { - TSG_USERNAME = username; - } - - @Value("${tsg.system.password}") - private void setTsgPassword(String password) { - TSG_PASSWORD = password; - } - @Value("${tsg.system.token}") private void setTsgToken(String token) { TSG_TOKEN = token; @@ -60,32 +48,8 @@ public class TsgUtil { if (StrUtil.isNotEmpty(TSG_TOKEN)) { return TSG_TOKEN; } - String token = ""; - Map map = Maps.newHashMap(); - map.put("username", TSG_USERNAME); - map.put("password", TSG_PASSWORD); - try { - Stopwatch watch = Stopwatch.createStarted(); - String response = HttpRequest.post(TSG_URL + "/v1/user/login") - .body(JSONUtil.toJsonStr(map)) - .timeout(httpTimeOut) - .execute().body(); - log.info("get tsg-api token, cost {} seconds", watch.elapsed(TimeUnit.SECONDS)); - if (StrUtil.isBlank(response)) { - log.error("failed to get TSG system token. response: {}", response); - throw new RuntimeException("ailed to get TSG system token. response: " + response); - } - JSONObject jsonObject = JSONUtil.parseObj(response); - if (!"200".equals(jsonObject.get("code").toString())) { - log.error("failed to get TSG system token. response: {}", response); - throw new RuntimeException("ailed to get TSG system token. response: " + response); - } - token = JSONUtil.parseObj(jsonObject.get("data")).get("token").toString(); - } catch (Exception e) { - log.error("failed to get TSG system token. message: {}", e.getMessage()); - throw e; - } - return token; + log.error("failed to get TSG system token."); + throw new IllegalArgumentException("failed to get TSG system token."); } public static void updateObjectById(Integer id, Map body) {