List<String> nullParams = Stream.of(
StringUtils.isBlank(client) ? "client" : null,
StringUtils.isBlank(redirect) ? "redirect" : null,
StringUtils.isBlank(unionId) ? "unionId" : null,
StringUtils.isBlank(openId) ? "openId" : null,
StringUtils.isBlank(wechatNickname) ? "wechatNickname" : null,
StringUtils.isBlank(wechatAvatar) ? "wechatAvatar" : null)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!nullParams.isEmpty()) {
throw new SaSsoException("参数不能为空: " + String.join(", ", nullParams));
}
Map<Boolean, List<String>> nullParams = Stream.of(
new AbstractMap.SimpleEntry<>("sign", sign),
new AbstractMap.SimpleEntry<>("timestamp", timestamp),
new AbstractMap.SimpleEntry<>("nonce", nonce))
.collect(Collectors.groupingBy(entry -> StringUtils.isBlank(entry.getValue()),
Collectors.mapping(Map.Entry::getKey, Collectors.toList())));
if (!nullParams.getOrDefault(true, Collections.emptyList()).isEmpty()) {
throw new SaSsoException("检验参数不能为空: " + String.join(", ", nullParams.get(true)));
}