Skip to content

Commit

Permalink
Merge pull request #279 from erupts/develop
Browse files Browse the repository at this point in the history
1.12.16
  • Loading branch information
erupts authored Nov 13, 2024
2 parents c5a83ca + c34ee21 commit 9dc38ee
Show file tree
Hide file tree
Showing 261 changed files with 639 additions and 40,000 deletions.
2 changes: 1 addition & 1 deletion erupt-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.15</version>
<version>1.12.16</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-annotation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.15</version>
<version>1.12.16</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ enum Mode {
SINGLE,
@Comment("依赖多行数据")
MULTI,
@Comment("仅依赖多行数据,屏蔽单行操作按钮")
MULTI_ONLY,
@Comment("不依赖行数据")
BUTTON
}
Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.15</version>
<version>1.12.16</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-node-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.15</version>
<version>1.12.16</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.15</version>
<version>1.12.16</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.15</version>
<version>1.12.16</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.15</version>
<version>1.12.16</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class GsonFactory {
return new JsonPrimitive(src);
}
})
.setObjectToNumberStrategy(ToNumberPolicy.LAZILY_PARSED_NUMBER)
.serializeNulls().setExclusionStrategies(new EruptGsonExclusionStrategies());

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class EruptConst {

public static final String ERUPT = "erupt";

public static final String ERUPT_AS = "et";

public static final String BASE_PACKAGE = "xyz.erupt";

public static final String ERUPT_DIR = ".erupt";
Expand All @@ -17,4 +19,7 @@ public class EruptConst {
public static final String DOT = ".";

public static final String ERUPT_LOG = "erupt-log";

public static final String AN = "abcdef0123456789";

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ public enum MenuStatus {
this.label = label;
}

public static MenuStatus valueOf(int value) {
for (MenuStatus menuStatus : MenuStatus.values()) {
if (menuStatus.getValue() == value) {
return menuStatus;
}
}
return null;
}

public static class ChoiceFetch implements ChoiceFetchHandler {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
package xyz.erupt.core.invoke;

import lombok.Getter;
import lombok.Setter;
import xyz.erupt.core.view.EruptModel;

/**
* @author YuePeng
* date 2024/6/29 15:38
*/
public class DataProxyContext {

private static final ThreadLocal<String[]> PRE_DATA_PROXY_THREADLOCAL = new ThreadLocal<>();
private static final ThreadLocal<Data> PRE_DATA_PROXY_THREADLOCAL = new ThreadLocal<>();

public static String[] params() {
return get().getParams();
}

public static Class<?> currentClass() {
return get().getEruptModel().getClazz();
}

public static Data get() {
return PRE_DATA_PROXY_THREADLOCAL.get();
}

static void set(String[] params) {
PRE_DATA_PROXY_THREADLOCAL.set(params);
static void set(Data data) {
PRE_DATA_PROXY_THREADLOCAL.set(data);
}

static void remove() {
PRE_DATA_PROXY_THREADLOCAL.remove();
}

@Getter
@Setter
public static class Data {

private EruptModel eruptModel;

private String[] params;

public Data(EruptModel eruptModel, String[] params) {
this.eruptModel = eruptModel;
this.params = params;
}

public Data() {
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import xyz.erupt.core.util.ReflectUtil;
import xyz.erupt.core.view.EruptModel;

import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Stream;

Expand All @@ -16,31 +19,48 @@
*/
public class DataProxyInvoke {

//@PreDataProxy的注解容器
private static final Set<Class<? extends Annotation>> dataProxyAnnotationContainer = new HashSet<>();

//注册支持@PreDataProxy注解的注解容器
public static void registerAnnotationContainer(Class<? extends Annotation> annotationClass) {
PreDataProxy preDataProxy = annotationClass.getAnnotation(PreDataProxy.class);
if (preDataProxy == null) throw new RuntimeException("register error not found @PreDataProxy");
dataProxyAnnotationContainer.add(annotationClass);
}

public static void invoke(EruptModel eruptModel, Consumer<DataProxy<Object>> consumer) {
//注解中的 @PreDataProxy
dataProxyAnnotationContainer.forEach(pc -> Optional.ofNullable(eruptModel.getClazz().getAnnotation(pc)).ifPresent(it -> {
PreDataProxy preDataProxy = it.annotationType().getAnnotation(PreDataProxy.class);
DataProxyContext.set(new DataProxyContext.Data(eruptModel, preDataProxy.params()));
consumer.accept(getInstanceBean(preDataProxy.value()));
DataProxyContext.remove();
}));
//父类及接口 @PreDataProxy
ReflectUtil.findClassExtendStack(eruptModel.getClazz()).forEach(clazz -> DataProxyInvoke.actionInvokePreDataProxy(clazz, consumer));
ReflectUtil.findClassExtendStack(eruptModel.getClazz()).forEach(clazz -> DataProxyInvoke.actionInvokePreDataProxy(eruptModel, clazz, consumer));
//本类及接口 @PreDataProxy
DataProxyInvoke.actionInvokePreDataProxy(eruptModel.getClazz(), consumer);
DataProxyInvoke.actionInvokePreDataProxy(eruptModel, eruptModel.getClazz(), consumer);
//@Erupt → DataProxy
Stream.of(eruptModel.getErupt().dataProxy()).forEach(proxy -> {
DataProxyContext.set(eruptModel.getErupt().dataProxyParams());
DataProxyContext.set(new DataProxyContext.Data(eruptModel, eruptModel.getErupt().dataProxyParams()));
consumer.accept(getInstanceBean(proxy));
DataProxyContext.remove();
});
}

private static void actionInvokePreDataProxy(Class<?> clazz, Consumer<DataProxy<Object>> consumer) {
private static void actionInvokePreDataProxy(EruptModel eruptModel, Class<?> clazz, Consumer<DataProxy<Object>> consumer) {
//接口
Stream.of(clazz.getInterfaces()).forEach(it -> Optional.ofNullable(it.getAnnotation(PreDataProxy.class))
.ifPresent(dataProxy -> {
DataProxyContext.set(dataProxy.params());
DataProxyContext.set(new DataProxyContext.Data(eruptModel, dataProxy.params()));
consumer.accept(getInstanceBean(dataProxy.value()));
DataProxyContext.remove();
}));
//类
Optional.ofNullable(clazz.getAnnotation(PreDataProxy.class))
.ifPresent(dataProxy -> {
DataProxyContext.set(dataProxy.params());
DataProxyContext.set(new DataProxyContext.Data(eruptModel, dataProxy.params()));
consumer.accept(getInstanceBean(dataProxy.value()));
DataProxyContext.remove();
});
Expand Down
5 changes: 2 additions & 3 deletions erupt-core/src/main/java/xyz/erupt/core/module/MetaMenu.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.erupt.core.module;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.core.constant.MenuStatus;
Expand All @@ -12,6 +13,7 @@
*/
@Getter
@Setter
@NoArgsConstructor
public class MetaMenu {

private Long id; //无需传递此参数
Expand All @@ -32,9 +34,6 @@ public class MetaMenu {

private MetaMenu parentMenu;

public MetaMenu() {
}

public static MetaMenu createRootMenu(String code, String name, String icon, Integer sort) {
MetaMenu metaMenu = new MetaMenu();
metaMenu.code = code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public class MetaUserinfo {

private List<String> roles; //角色列表

private String tenantId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ protected Object invocation(MethodInvocation invocation) {
View[] views = this.rawAnnotation.views();
List<View> proxyViews = new ArrayList<>();
for (View view : views) {
if (ExprInvoke.getExpr(view.ifRender())) {
if (ProxyContext.get().isStarting() || ExprInvoke.getExpr(view.ifRender())) {
proxyViews.add(AnnotationProxyPool.getOrPut(view, annotation -> new ViewProxy().newProxy(annotation, this)));
}
}
return proxyViews.toArray(new View[0]);
} else if (super.matchMethod(invocation, EruptField::edit)) {
Edit edit = this.rawAnnotation.edit();
if (ExprInvoke.getExpr(edit.ifRender())) {
if (ProxyContext.get().isStarting() || ExprInvoke.getExpr(edit.ifRender())) {
return AnnotationProxyPool.getOrPut(edit, annotation -> new EditProxy().newProxy(annotation, this));
} else {
return tplEruptField.edit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ public class ProxyContext {

private boolean i18n = false;

private boolean starting = false;

public static void set(Class<?> clazz) {
proxyContextThreadLocal.get().setClazz(clazz);
proxyContextThreadLocal.get().setI18n(null != clazz.getAnnotation(EruptI18n.class));
}

public static void set(Field field) {
public static void set(Field field, boolean starting) {
proxyContextThreadLocal.get().setField(field);
ProxyContext.set(field.getDeclaringClass());
proxyContextThreadLocal.get().setStarting(starting);
set(field.getDeclaringClass());
}

public static ProxyContext get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.fusesource.jansi.Ansi;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
Expand All @@ -26,6 +27,8 @@
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

import static org.fusesource.jansi.Ansi.ansi;

/**
* @author YuePeng
* date 9/28/18.
Expand Down Expand Up @@ -54,7 +57,7 @@ public static EruptModel getErupt(String eruptName) {
if (null == ERUPTS.get(eruptName)) {
return null;
} else {
return EruptCoreService.initEruptModel(ERUPTS.get(eruptName).getClazz());
return EruptCoreService.initEruptModel(ERUPTS.get(eruptName).getClazz(), false);
}
} else {
return ERUPTS.get(eruptName);
Expand All @@ -66,7 +69,7 @@ public static void registerErupt(Class<?> eruptClazz) {
if (ERUPTS.containsKey(eruptClazz.getSimpleName())) {
throw new RuntimeException(eruptClazz.getSimpleName() + " conflict !");
}
EruptModel eruptModel = initEruptModel(eruptClazz);
EruptModel eruptModel = initEruptModel(eruptClazz, true);
ERUPTS.put(eruptClazz.getSimpleName(), eruptModel);
ERUPT_LIST.add(eruptModel);
}
Expand All @@ -91,15 +94,15 @@ public static EruptModel getEruptView(String eruptName) {
return em;
}

private static EruptModel initEruptModel(Class<?> clazz) {
private static EruptModel initEruptModel(Class<?> clazz, boolean starting) {
// erupt class data to memory
EruptModel eruptModel = new EruptModel(clazz);
// erupt field data to memory
eruptModel.setEruptFieldModels(new ArrayList<>());
eruptModel.setEruptFieldMap(new LinkedCaseInsensitiveMap<>());
ReflectUtil.findClassAllFields(clazz, field -> Optional.ofNullable(field.getAnnotation(EruptField.class))
.ifPresent(ignore -> {
EruptFieldModel eruptFieldModel = new EruptFieldModel(field);
EruptFieldModel eruptFieldModel = new EruptFieldModel(field, starting);
eruptModel.getEruptFieldModels().add(eruptFieldModel);
if (!eruptModel.getEruptFieldMap().containsKey(field.getName())) {
eruptModel.getEruptFieldMap().put(field.getName(), eruptFieldModel);
Expand All @@ -119,20 +122,19 @@ public void run(ApplicationArguments args) {
EruptSpringUtil.scannerPackage(EruptApplication.getScanPackage(), new TypeFilter[]{
new AnnotationTypeFilter(Erupt.class)
}, clazz -> {
EruptModel eruptModel = initEruptModel(clazz);
EruptModel eruptModel = initEruptModel(clazz, true);
ERUPTS.put(clazz.getSimpleName(), eruptModel);
ERUPT_LIST.add(eruptModel);
});
log.info("<" + repeat("===", 20) + ">");
log.info("<{}>", repeat("===", 20));
AtomicInteger moduleMaxCharLength = new AtomicInteger();
EruptModuleInvoke.invoke(it -> {
int length = it.info().getName().length();
if (length > moduleMaxCharLength.get()) moduleMaxCharLength.set(length);
});
// if (eruptProp.isHotBuild()) {
// hotBuild = eruptProp.isHotBuild();
// log.info(ansi().fg(Ansi.Color.RED).a("Erupt Hot Build").reset().toString());
// }
if (EruptSpringUtil.getBean(EruptProp.class).isHotBuild()) {
log.warn(ansi().fg(Ansi.Color.RED).a("Open erupt hot build").reset().toString());
}
EruptModuleInvoke.invoke(it -> {
it.run();
MODULES.add(it.info().getName());
Expand All @@ -143,7 +145,7 @@ public void run(ApplicationArguments args) {
log.info("Erupt modules : {}", MODULES.size());
log.info("Erupt classes : {}", ERUPTS.size());
log.info("Erupt Framework initialization completed in {}ms", totalRecorder.recorder());
log.info("<" + repeat("===", 20) + ">");
log.info("<{}>", repeat("===", 20));
}

private String fillCharacter(String character, int targetWidth) {
Expand Down
Loading

0 comments on commit 9dc38ee

Please sign in to comment.