SSO模块增加 server-url 属性,用于简化各种 url 配置

This commit is contained in:
click33
2022-08-15 09:14:28 +08:00
parent 4a3f4fa548
commit 5434ee8800
5 changed files with 103 additions and 13 deletions

View File

@@ -178,12 +178,36 @@ public final class SaStrategy {
// 默认使用jdk的注解处理器
return element.getAnnotation(annotationClass);
};
/**
* 拼接两个url
* <p> 例如url1=http://domain.cnurl2=/sso/auth则返回http://domain.cn/sso/auth
* <p> 参数 [第一个url, 第二个url]
*/
public BiFunction<String, String, String> spliceTwoUrl = (url1, url2) -> {
// q1、任意一个为空则直接返回另一个
if(url1 == null) {
return url2;
}
if(url2 == null) {
return url1;
}
// q2、如果 url2 以 http 开头,将其视为一个完整地址
if(url2.startsWith("http")) {
return url2;
}
// q3、将两个地址拼接在一起
return url1 + url2;
};
//
// 重写策略 set连缀风格
//
/**
* 重写创建 Token 的策略
* <p> 参数 [账号id, 账号类型]
@@ -249,6 +273,17 @@ public final class SaStrategy {
this.getAnnotation = getAnnotation;
return this;
}
/**
* 拼接两个url
* <p> 例如url1=http://domain.cnurl2=/sso/auth则返回http://domain.cn/sso/auth
* <p> 参数 [第一个url, 第二个url]
*
* @param spliceTwoUrl 要设置的 spliceTwoUrl
*/
public void setSpliceTwoUrl(BiFunction<String, String, String> spliceTwoUrl) {
this.spliceTwoUrl = spliceTwoUrl;
}
}