配置迁移到数据库表里
This commit is contained in:
@@ -47,6 +47,87 @@ public final class LbThirdIntegrationConfigUtil {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public static String resolveUserSelectBaseUrl(LbThirdIntegrationConfig config) {
|
||||
String base = trimTrailingSlash(requireText(config.getAdminBaseUrl(), "adminBaseUrl"));
|
||||
String path = config.getUserSelectPath();
|
||||
if (!StringUtils.hasText(path)) {
|
||||
path = LbThirdIntegrationConstants.DEFAULT_USER_SELECT_PATH;
|
||||
}
|
||||
path = path.trim();
|
||||
if (!path.startsWith("/")) {
|
||||
path = "/" + path;
|
||||
}
|
||||
return base + path;
|
||||
}
|
||||
|
||||
public static String resolveUserReferer(LbThirdIntegrationConfig config) {
|
||||
if (StringUtils.hasText(config.getUserReferer())) {
|
||||
return config.getUserReferer().trim();
|
||||
}
|
||||
return trimTrailingSlash(requireText(config.getAdminBaseUrl(), "adminBaseUrl"))
|
||||
+ "/app/admin/user/index";
|
||||
}
|
||||
|
||||
public static int resolveUserPageLimit(LbThirdIntegrationConfig config) {
|
||||
Integer limit = config.getUserPageLimit();
|
||||
if (limit == null || limit < 1) {
|
||||
return LbThirdIntegrationConstants.DEFAULT_USER_PAGE_LIMIT;
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
public static String resolveOrderSelectBaseUrl(LbThirdIntegrationConfig config) {
|
||||
String base = trimTrailingSlash(requireText(config.getAdminBaseUrl(), "adminBaseUrl"));
|
||||
String path = config.getOrderSelectPath();
|
||||
if (!StringUtils.hasText(path)) {
|
||||
path = LbThirdIntegrationConstants.DEFAULT_ORDER_SELECT_PATH;
|
||||
}
|
||||
path = path.trim();
|
||||
if (!path.startsWith("/")) {
|
||||
path = "/" + path;
|
||||
}
|
||||
return base + path;
|
||||
}
|
||||
|
||||
public static String resolveOrderReferer(LbThirdIntegrationConfig config) {
|
||||
if (StringUtils.hasText(config.getOrderReferer())) {
|
||||
return config.getOrderReferer().trim();
|
||||
}
|
||||
return trimTrailingSlash(requireText(config.getAdminBaseUrl(), "adminBaseUrl"))
|
||||
+ "/app/admin/order/index";
|
||||
}
|
||||
|
||||
public static int resolveOrderPageLimit(LbThirdIntegrationConfig config) {
|
||||
Integer limit = config.getOrderPageLimit();
|
||||
if (limit == null || limit < 1) {
|
||||
return LbThirdIntegrationConstants.DEFAULT_ORDER_PAGE_LIMIT;
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装 Cookie 请求头:优先完整 cookie,否则 {@code PHPSID=} + phpsid。
|
||||
*/
|
||||
public static String resolveCookieHeader(LbThirdIntegrationConfig config) {
|
||||
String c = firstNonBlank(config.getCookie());
|
||||
if (c != null) {
|
||||
return c;
|
||||
}
|
||||
String id = firstNonBlank(config.getPhpsid());
|
||||
if (id != null) {
|
||||
return "PHPSID=" + id;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String firstNonBlank(String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
String t = s.trim();
|
||||
return t.isEmpty() ? null : t;
|
||||
}
|
||||
|
||||
private static String requireText(String value, String fieldName) {
|
||||
if (!StringUtils.hasText(value)) {
|
||||
throw new IllegalStateException(fieldName + " 未配置");
|
||||
|
||||
Reference in New Issue
Block a user