feat: update oauth property validator
This commit is contained in:
parent
b31015cb36
commit
bc95e61369
|
@ -8,6 +8,7 @@ import com.databasir.core.domain.app.data.OAuthAppUpdateRequest;
|
|||
import com.databasir.core.domain.app.data.OauthAppPropertyData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -23,7 +24,7 @@ public class OauthPropertiesValidator {
|
|||
public void validate(OAuthAppCreateRequest request, List<OAuthAppPlatformResponse> platforms) {
|
||||
Map<String, OauthAppPropertyData> propertyMapByName = request.getProperties()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(i -> i.getName(), i -> i));
|
||||
.collect(Collectors.toMap(OauthAppPropertyData::getName, i -> i));
|
||||
platforms.stream()
|
||||
.filter(platform -> platform.getAuthAppType() == request.getAppType())
|
||||
.forEach(platform -> {
|
||||
|
@ -32,7 +33,11 @@ public class OauthPropertiesValidator {
|
|||
if (Objects.equals(true, property.getRequired())) {
|
||||
if (!propertyMapByName.containsKey(property.getName())) {
|
||||
throw DomainErrors.MISS_REQUIRED_PARAMETERS.exception(
|
||||
"参数 " + property.getName() + " 不能为空");
|
||||
property.getLabel() + " 不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(propertyMapByName.get(property.getName()).getValue())) {
|
||||
throw DomainErrors.MISS_REQUIRED_PARAMETERS.exception(
|
||||
property.getLabel() + " 不能为空");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -42,7 +47,7 @@ public class OauthPropertiesValidator {
|
|||
public void validate(OAuthAppUpdateRequest request, List<OAuthAppPlatformResponse> platforms) {
|
||||
Map<String, OauthAppPropertyData> propertyMapByName = request.getProperties()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(i -> i.getName(), i -> i));
|
||||
.collect(Collectors.toMap(OauthAppPropertyData::getName, i -> i));
|
||||
platforms.stream()
|
||||
.filter(platform -> platform.getAuthAppType() == request.getAppType())
|
||||
.forEach(platform -> {
|
||||
|
@ -51,7 +56,11 @@ public class OauthPropertiesValidator {
|
|||
if (Objects.equals(true, property.getRequired())) {
|
||||
if (!propertyMapByName.containsKey(property.getName())) {
|
||||
throw DomainErrors.MISS_REQUIRED_PARAMETERS.exception(
|
||||
"参数 " + property.getName() + " 不能为空");
|
||||
property.getLabel() + " 不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(propertyMapByName.get(property.getName()).getValue())) {
|
||||
throw DomainErrors.MISS_REQUIRED_PARAMETERS.exception(
|
||||
property.getLabel() + " 不能为空");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue