publish 0.0.5

This commit is contained in:
曾文豪
2023-01-09 15:20:52 +08:00
parent e61b82d026
commit 7c6ab72016
57 changed files with 1381 additions and 305 deletions

View File

@@ -0,0 +1,57 @@
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;
/**
* @author hao
*/
@Service
public class LoginService {
@Value("${tiesheng.global.host}")
String globalHost;
@Autowired(required = false)
TieshengLoginConfigurer tieshengLoginConfigurer;
/**
* 检查配置
*/
public void checkLoginConfigurer(Consumer<TieshengLoginConfigurer> consumer) {
if (tieshengLoginConfigurer == null) {
throw new ApiException("未配置登录逻辑");
}
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;
}
}