提交openapi单元测试代码

调整接口管理的字段位置
授权管理删掉无用配置
授权管理编辑改为重置生成ak sk功能
授权页面应该改成跟角色授权类型的效果
This commit is contained in:
xlh12306
2025-05-16 23:12:28 +08:00
parent 9aea5de668
commit fb188a83a1
14 changed files with 211 additions and 47 deletions

View File

@ -8,6 +8,8 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.Map;
@ -30,6 +32,10 @@ public class RestUtil {
// 微服务版集成企业微信单点登录
// 因为微服务版没有端口号,导致 SpringContextUtils.getDomain() 方法获取的域名的端口号变成了:-1所以出问题了只需要把这个-1给去掉就可以了。
String port=":-1";
//单元测试导致无端口号的问题
if (!domain.endsWith(port)){
checkAndAddPort();
}
if (domain.endsWith(port)) {
domain = domain.substring(0, domain.length() - 3);
}
@ -37,12 +43,31 @@ public class RestUtil {
return domain;
}
private static void checkAndAddPort() {
try {
URL url = new URL(domain);
int port = url.getPort();
if (port == -1) {
domain = domain+":"+getPort();
}
} catch (MalformedURLException e) {
log.warn("获取端口号异常");
}
}
private static String getPath() {
if (path == null) {
path = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path");
}
return oConvertUtils.getString(path);
}
private static String getPort() {
String property = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.port");
if (StringUtils.isEmpty(property)||"0".equals(property)) {
property = "8080";
}
return oConvertUtils.getString(property);
}
public static String getBaseUrl() {
String basepath = getDomain() + getPath();