feat:提供校验文案关键字替换能力
This commit is contained in:
parent
a5ecb363bb
commit
2dddab4f31
@ -9,6 +9,7 @@ import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Document
|
||||
@ -29,6 +30,7 @@ public abstract class Domain implements Po, Serializable {
|
||||
* 编号
|
||||
*/
|
||||
@Property(title = "编码", inherited = true)
|
||||
@NotBlank(message = "编码不可为空")
|
||||
protected String code;
|
||||
|
||||
/**
|
||||
@ -36,6 +38,7 @@ public abstract class Domain implements Po, Serializable {
|
||||
*/
|
||||
@Indexed
|
||||
@Property(title = "名称", inherited = true)
|
||||
@NotBlank(message = "名称不可为空")
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.flyfish.framework.beans.meta;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.flyfish.framework.annotations.Properties;
|
||||
import com.flyfish.framework.annotations.*;
|
||||
import com.flyfish.framework.beans.enums.ValidationCandidate;
|
||||
@ -10,6 +13,7 @@ import com.flyfish.framework.utils.ReflectionUtils;
|
||||
import com.flyfish.framework.utils.StringFormats;
|
||||
import lombok.Data;
|
||||
import lombok.val;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
@ -54,8 +58,13 @@ public class BeanProperty {
|
||||
private BeanPropertyType type;
|
||||
|
||||
// 只读属性,不生成于表单
|
||||
@JsonIgnore
|
||||
private transient boolean readonly;
|
||||
|
||||
// 继承属性,不生成于表单
|
||||
@JsonIgnore
|
||||
private transient boolean inherited;
|
||||
|
||||
// 属性
|
||||
private Map<String, Object> props;
|
||||
|
||||
@ -106,6 +115,7 @@ public class BeanProperty {
|
||||
property.setTitle(props.inherited() ? parentName + props.title() : props.title());
|
||||
property.setDescription(props.description());
|
||||
property.setReadonly(props.readonly());
|
||||
property.setInherited(props.inherited());
|
||||
property.setGroup(props.group());
|
||||
// 优雅地设置排序
|
||||
MergedAnnotation<Order> order = annotations.get(Order.class);
|
||||
@ -277,7 +287,6 @@ public class BeanProperty {
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
BeanProperty property = found.get();
|
||||
property.title = prop.title();
|
||||
if (prop.order() != 0) {
|
||||
property.order = prop.order();
|
||||
}
|
||||
@ -288,6 +297,13 @@ public class BeanProperty {
|
||||
if (prop.readonly()) {
|
||||
origin.remove(property);
|
||||
}
|
||||
// 存在校验,替换名称文案(仅inherit)
|
||||
if (property.inherited && CollectionUtils.isNotEmpty(property.validation)) {
|
||||
property.validation.forEach(validation -> validation.setMessage(validation.getMessage()
|
||||
.replace(property.title, prop.title())));
|
||||
}
|
||||
// 设置标题
|
||||
property.title = prop.title();
|
||||
} else {
|
||||
BeanProperty property = new BeanProperty();
|
||||
property.setType(BeanPropertyType.STRING);
|
||||
|
Loading…
Reference in New Issue
Block a user