diff --git a/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProperty.java b/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProperty.java index 68a053a..6a3916c 100644 --- a/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProperty.java +++ b/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProperty.java @@ -113,7 +113,7 @@ public class BeanProperty { // 开始解析关键注解 if (annotations.isPresent(Property.class)) { Property props = annotations.get(Property.class).synthesize(); - // 只有存在馆建注解,才会进行初始化 + // 只有存在关键注解,才会进行初始化 String parentName = Optional.ofNullable(beanClass.getAnnotation(RestBean.class)) .map(RestBean::name).orElse(""); property.setDescription(props.description()); @@ -148,7 +148,19 @@ public class BeanProperty { // 优雅的设置联动映射 MergedAnnotation mapping = annotations.get(MappedTo.class); if (mapping.isPresent()) { - property.extra.put("mapping", mapping.asMap()); + property.extra.put(BeanProps.MAPPING, mapping.asMap()); + } + // 处理联动 + MergedAnnotation condition = annotations.get(ConditionOn.List.class); + if (condition.isPresent()) { + property.extra.put(BeanProps.CONDITION, Arrays.stream( + condition.getAnnotationArray("value", ConditionOn.class) + ).map(MergedAnnotation::asMap).collect(Collectors.toList())); + } else { + MergedAnnotation single = annotations.get(ConditionOn.class); + if (single.isPresent()) { + property.extra.put(BeanProps.CONDITION, Collections.singletonList(single.asMap())); + } } // 优雅的处理校验 property.setValidation(ValidationCandidate.produce(annotations)); @@ -190,7 +202,7 @@ public class BeanProperty { break; case NUMBER: if (null != field) { - if (annotations.isPresent(Money.class) && !property.extra.containsKey("component")) { + if (annotations.isPresent(Money.class) && !property.extra.containsKey(BeanProps.COMPONENT)) { property.extra.put(BeanProps.COMPONENT, "money-input"); } } @@ -328,13 +340,16 @@ public class BeanProperty { } // 处理额外的映射 if (ArrayUtils.isNotEmpty(prop.mapping())) { - property.extra.put("mapping", MergedAnnotations.from(prop.mapping()).get(MappedTo.class).asMap()); + property.extra.put(BeanProps.MAPPING, MergedAnnotations.from(prop.mapping()).get(MappedTo.class).asMap()); } // 处理值生成策略,此处可清除原策略 if (ArrayUtils.isNotEmpty(prop.generated())) { property.extra.put(BeanProps.GENERATED, MergedAnnotations.from(prop.mapping()).get(MappedTo.class).asMap()); } else { property.extra.remove(BeanProps.GENERATED); + if ("input-hidden".equals(property.extra.get(BeanProps.COMPONENT))) { + property.extra.remove(BeanProps.COMPONENT); + } } // 设置标题 property.title = prop.title(); diff --git a/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProps.java b/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProps.java index 1ad7ecf..be44dbc 100644 --- a/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProps.java +++ b/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProps.java @@ -21,4 +21,8 @@ public interface BeanProps { String COMPONENT = "component"; String GENERATED = "generated"; + + String MAPPING = "mapping"; + + String CONDITION = "condition"; }