feat:实现缺省的code规则
This commit is contained in:
parent
f459899a53
commit
04b2152ab7
@ -4,8 +4,11 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 框架配置
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
@Setter
|
||||
@ -18,4 +21,6 @@ public class FrameworkConfiguration {
|
||||
private boolean debug = false;
|
||||
|
||||
private boolean shortPassword = false;
|
||||
|
||||
private Supplier<String> codeSupplier = null;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package com.flyfish.framework.constant;
|
||||
|
||||
import com.flyfish.framework.config.FrameworkConfiguration;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 框架静态配置
|
||||
*
|
||||
@ -25,4 +27,16 @@ public interface Frameworks {
|
||||
config.setDebug(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
static FrameworkConfiguration codeSupplier(Supplier<String> codeSupplier) {
|
||||
config.setCodeSupplier(codeSupplier);
|
||||
return config;
|
||||
}
|
||||
|
||||
static String getCode() {
|
||||
if (null != config.getCodeSupplier()) {
|
||||
return config.getCodeSupplier().get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.flyfish.framework.domain.base;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.flyfish.framework.annotations.Generation;
|
||||
import com.flyfish.framework.annotations.Property;
|
||||
import com.flyfish.framework.constant.Frameworks;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
@ -33,7 +34,7 @@ public abstract class Domain implements Po, Named, Serializable {
|
||||
@Property(title = "编码", inherited = true)
|
||||
@NotBlank(message = "编码不可为空")
|
||||
@Generation(Generation.Strategy.CODE)
|
||||
protected String code;
|
||||
protected String code = Frameworks.getCode();
|
||||
|
||||
/**
|
||||
* 名称
|
||||
|
@ -11,6 +11,7 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
public final class FieldUtils {
|
||||
|
||||
|
||||
public static <T> T complete(T value, Supplier<T> supplier) {
|
||||
return ObjectUtils.isEmpty(value) ? supplier.get() : value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user