Hi Community,
I have an idea. Optimize and verify shenyu-admin module interface parameters
Use validation for parameter verification, clear the verification in the code
[in service].
Expand the annotation of validation to simplify the verification logic.
For example:
1.Add annotation:
public @interface Existed {
String message() default "the key is not existed!";
Class existProvider();
}
2.Add interface:
public interface ExistProvider {
default boolean notExisted(Serializable key) {
return !Boolean.TRUE.equals(existed(key));
}
Boolean existed(Serializable key);
}
3. implements ConstraintValidator
4.used in my code:
XXXMapper extend ExistProvider
Add sql implements in XXXMapper : select true from table where xxx limit 1
Used in controller api :@Existed(mapper = XXXMapper.class, message = "the
obejct data not existed”)
thanks.