perf:优化ip2region,改为从服务器下载db文件,而不是打包到项目中

This commit is contained in:
yz
2023-01-09 22:50:47 +08:00
parent 53e35ccb52
commit dd87b00612
14 changed files with 101 additions and 47 deletions

View File

@@ -15,6 +15,7 @@ import com.tiesheng.platform.config.ding.bean.DingUserInfo;
import com.tiesheng.platform.config.wxmp.PlatformWxmpConfig;
import com.tiesheng.platform.config.wxmp.bean.WxJsapiSignature;
import com.tiesheng.platform.config.wxmp.bean.WxUserInfo;
import com.tiesheng.util.config.GlobalConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +43,8 @@ public class LoginController {
LoginService loginService;
@Autowired
TsTokenConfig tsTokenConfig;
@Autowired
GlobalConfig globalConfig;
/**
@@ -105,7 +108,7 @@ public class LoginController {
map.put("extra", extra);
loginService.checkLoginConfigurer(s -> {
String query = URLUtil.buildQuery(map, Charset.defaultCharset());
String configUrl = loginService.buildPath("/ding/index.html?" + query);
String configUrl = globalConfig.buildPath("/ding/index.html?" + query);
try {
response.sendRedirect(configUrl);
} catch (IOException ignored) {
@@ -162,7 +165,7 @@ public class LoginController {
if (StrUtil.isEmpty(extra)) {
extra = "";
}
String configUrl = loginService.buildPath("/auth/wxmp/oauth2/" + service + "?extra=" + extra);
String configUrl = globalConfig.buildPath("/auth/wxmp/oauth2/" + service + "?extra=" + extra);
String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl, "snsapi_userinfo");
response.sendRedirect(authorizationUrl);
}

View File

@@ -1,11 +1,8 @@
package com.tiesheng.login.service;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.tiesheng.login.config.TieshengLoginConfigurer;
import com.tiesheng.util.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.function.Consumer;
@@ -16,8 +13,6 @@ import java.util.function.Consumer;
@Service
public class LoginService {
@Value("${tiesheng.global.host}")
String globalHost;
@Autowired(required = false)
TieshengLoginConfigurer tieshengLoginConfigurer;
@@ -32,26 +27,4 @@ public class LoginService {
consumer.accept(tieshengLoginConfigurer);
}
public String getContextPath() {
String context = SpringUtil.getProperty("server.servlet.context-path");
if (StrUtil.isEmpty(context)) {
context = "";
}
return context;
}
public String buildPath(String path) {
if (StrUtil.isEmpty(path)) {
path = "";
}
if (!StrUtil.isEmpty(this.globalHost) && !StrUtil.startWith(path, "http")) {
path = this.globalHost + this.getContextPath() + path;
}
return path;
}
}