|
|
@ -11,24 +11,37 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.util.StringUtils; |
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@Service |
|
|
@Service |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
public class PlatformConfigurationServiceImpl extends ServiceImpl<PlatformConfigurationMapper, PlatformConfiguration> implements PlatformConfigurationService { |
|
|
public class PlatformConfigurationServiceImpl extends ServiceImpl<PlatformConfigurationMapper, PlatformConfiguration> implements PlatformConfigurationService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public String getPlatformNameBySourceUrl(String sourceUrl) { |
|
|
public String getPlatformNameBySourceUrl(String sourceUrl) { |
|
|
if (!StringUtils.hasText(sourceUrl)) { |
|
|
if (!StringUtils.hasText(sourceUrl)) { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
LambdaQueryWrapper<PlatformConfiguration> wrapper = Wrappers.lambdaQuery(); |
|
|
List<String> inputDomains = Arrays.stream(sourceUrl.split("\n")) |
|
|
|
|
|
.map(String::trim) |
|
|
|
|
|
.filter(StringUtils::hasText) |
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
wrapper.eq(PlatformConfiguration::getDomainName, sourceUrl); |
|
|
List<PlatformConfiguration> allConfigs = this.list(); |
|
|
|
|
|
|
|
|
|
|
|
for (String input : inputDomains) { |
|
|
|
|
|
for (PlatformConfiguration config : allConfigs) { |
|
|
|
|
|
String dbDomain = config.getDomainName(); |
|
|
|
|
|
if (StringUtils.hasText(dbDomain) && dbDomain.contains(input)) { |
|
|
|
|
|
log.info("【匹配成功】平台:{},匹配规则:{}", config.getPlatformName(), input); |
|
|
|
|
|
return config.getPlatformName(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
PlatformConfiguration config = this.getOne(wrapper); |
|
|
return null; |
|
|
log.info("【测试】前端传的uniqueToken:{}",config ); |
|
|
|
|
|
return config != null ? config.getPlatformName() : null; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |