Skip to content

Commit

Permalink
Merge pull request #243 from erupts/develop
Browse files Browse the repository at this point in the history
1.12.11
  • Loading branch information
erupts authored Apr 14, 2024
2 parents f25029d + db7deb4 commit 867c065
Show file tree
Hide file tree
Showing 93 changed files with 602 additions and 344 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.10</version>
<version>1.12.11</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.10</version>
<version>1.12.11</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@Deprecated
public @interface AutoFill {

@Deprecated
String value();

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/
public class AnnotationConst {

public static final String VALUE = "value";

public static final String ID = "id";

public static final String LABEL = "name";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package xyz.erupt.annotation.sub_erupt;

import xyz.erupt.annotation.config.AutoFill;
import xyz.erupt.annotation.config.Comment;
import xyz.erupt.annotation.expr.ExprBool;

Expand All @@ -12,8 +11,6 @@
*/
public @interface Drill {

@Deprecated
@AutoFill("T(Integer).toString(#item.title().hashCode())")
String code() default "";

String title();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package xyz.erupt.annotation.sub_erupt;

import xyz.erupt.annotation.config.AutoFill;
import xyz.erupt.annotation.config.Comment;
import xyz.erupt.annotation.expr.ExprBool;
import xyz.erupt.annotation.fun.OperationHandler;
Expand All @@ -15,17 +14,20 @@
*/
public @interface RowOperation {

@Deprecated
@AutoFill("T(Integer).toString(#item.title().hashCode())")
String code() default "";

String title();

@Transient
ExprBool show() default @ExprBool;

@Comment("功能提示")
String tip() default "";

@Comment("调用提示,空则不提示")
String callHint() default "erupt.operation.call_hint";


@Comment("图标请参考Font Awesome")
String icon() default "fa fa-dot-circle-o";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
public enum ViewType {
@Comment("根据返回值等特征自动判断")
AUTO,
@Comment("普通文字")
@Comment("普通文文本")
TEXT,
@Comment("安全文本渲染")
SAFE_TEXT,
@Comment("图片")
IMAGE,
@Comment("图片BASE64")
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.10</version>
<version>1.12.11</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.10</version>
<version>1.12.11</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.10</version>
<version>1.12.11</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.10</version>
<version>1.12.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import xyz.erupt.core.util.Erupts;
import xyz.erupt.jpa.dao.EruptDao;
import xyz.erupt.jpa.model.MetaModelUpdateVo;
import xyz.erupt.linq.lambda.LambdaSee;
import xyz.erupt.tpl.engine.EngineConst;
import xyz.erupt.upms.handler.ViaMenuValueCtrl;

Expand Down Expand Up @@ -62,13 +63,9 @@
@EruptI18n
public class CloudNode extends MetaModelUpdateVo implements DataProxy<CloudNode>, TagsFetchHandler, Tpl.TplHandler {

public static final String NODE_NAME = "nodeName";
public static final String NODE_NAME = LambdaSee.field(CloudNode::getNodeName);

private static final String REGISTER_TYPE = "registerType";

private static final String ADDRESSES = "addresses";

public static final String ACCESS_TOKEN = "accessToken";
public static final String ACCESS_TOKEN = LambdaSee.field(CloudNode::getAccessToken);

@Column(unique = true)
@EruptField(
Expand Down Expand Up @@ -181,26 +178,21 @@ public void afterFetch(Collection<Map<String, Object>> list) {
String token = it.toString();
map.put(ACCESS_TOKEN, token.substring(0, 3) + "******" + token.substring(token.length() - 3));
});
String eruptNumStr = "eruptNum";
String instanceNumStr = "instanceNum";
String version = "version";
String eruptModuleNum = "eruptModuleNum";
map.put(eruptNumStr, '-');
map.put(instanceNumStr, '-');
map.put(version, '-');
map.put(eruptModuleNum, '-');
map.put(LambdaSee.field(CloudNode::getEruptNum), '-');
map.put(LambdaSee.field(CloudNode::getInstanceNum), '-');
map.put(LambdaSee.field(CloudNode::getVersion), '-');
map.put(LambdaSee.field(CloudNode::getEruptModuleNum), '-');
try {
MetaNode metaNode = nodeManager.getNode(map.get(NODE_NAME).toString());
Optional.ofNullable(nodeManager.getNode(map.get(NODE_NAME).toString())).ifPresent(metaNode1 -> {
Function<Collection<String>, Object> function = (it) -> null == it ? 0 : String.format("<a href='javascript:alert(\"%s\");'>%d</a>",
String.join("\\u000a", it), it.size());
map.put(eruptNumStr, function.apply(metaNode.getErupts()));
map.put(instanceNumStr, metaNode.getLocations().size());
map.put(eruptModuleNum, function.apply(metaNode.getEruptModules()));
map.put(version, metaNode.getVersion());
Function<Collection<String>, Object> function = (it) -> null == it ? 0 : String.format("<a href='javascript:alert(`%s`);'>%d</a>", String.join("\\u000a", it), it.size());
map.put(LambdaSee.field(CloudNode::getEruptNum), function.apply(metaNode.getErupts()));
map.put(LambdaSee.field(CloudNode::getInstanceNum), metaNode.getLocations().size());
map.put(LambdaSee.field(CloudNode::getEruptModuleNum), function.apply(metaNode.getEruptModules()));
map.put(LambdaSee.field(CloudNode::getVersion), metaNode.getVersion());
});
} catch (Exception e) {
map.put(version, String.format("<span style='color:#f00'>%s</span>", e.getMessage()));
map.put(LambdaSee.field(CloudNode::getVersion), String.format("<span style='color:#f00'>%s</span>", e.getMessage()));
log.warn("node warn → " + map.get(NODE_NAME), e);
}
}
Expand Down
7 changes: 6 additions & 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.10</version>
<version>1.12.11</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -52,6 +52,11 @@
<artifactId>jansi</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>${erupt.groupId}</groupId>
<artifactId>linq.j</artifactId>
<version>0.0.4</version>
</dependency>
</dependencies>

<build>
Expand Down
11 changes: 3 additions & 8 deletions erupt-core/src/main/java/xyz/erupt/core/config/GsonFactory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.erupt.core.config;

import com.google.gson.*;
import lombok.Getter;
import xyz.erupt.core.util.DateUtil;

import java.math.BigDecimal;
Expand All @@ -14,6 +15,7 @@
*/
public class GsonFactory {

@Getter
private final static GsonBuilder gsonBuilder = new GsonBuilder().setDateFormat(DateUtil.DATE_TIME)
.registerTypeAdapter(LocalDateTime.class, (JsonSerializer<LocalDateTime>) (src, typeOfSrc, context)
-> new JsonPrimitive(src.format(DateTimeFormatter.ofPattern(DateUtil.DATE_TIME))))
Expand All @@ -28,16 +30,9 @@ public class GsonFactory {
.registerTypeAdapter(BigDecimal.class, (JsonSerializer<BigDecimal>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
.serializeNulls().setExclusionStrategies(new EruptGsonExclusionStrategies());

@Getter
private static final Gson gson = gsonBuilder.create();

public static Gson getGson() {
return gson;
}

public static GsonBuilder getGsonBuilder() {
return gsonBuilder;
}

private GsonFactory() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ public static void validateEruptFieldInfo(EruptFieldModel eruptFieldModel) {
switch (edit.type()) {
case REFERENCE_TREE:
case REFERENCE_TABLE:
if (eruptFieldModel.getEruptField().views().length > 0) {
for (View view : eruptFieldModel.getEruptField().views()) {
if ("".equals(view.column())) {
throw ExceptionAnsi.styleEruptFieldException(eruptFieldModel, "@View注解修饰复杂对象,必须配置column值 → " + view.title());
}
for (View view : eruptFieldModel.getEruptField().views()) {
if ("".equals(view.column())) {
throw ExceptionAnsi.styleEruptFieldException(eruptFieldModel, "@View注解修饰复杂对象,必须配置column值 → " + view.title());
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.framework.ProxyFactory;
import xyz.erupt.linq.lambda.LambdaSee;
import xyz.erupt.linq.lambda.SFunction;

import java.lang.annotation.Annotation;

/**
* 注解代理
Expand Down Expand Up @@ -45,4 +49,8 @@ public Object invoke(MethodInvocation invocation) {
return invocation.getMethod().invoke(invocation.getThis());
}

public <T extends Annotation, R> boolean matchMethod(MethodInvocation invocation, SFunction<T, R> annoLambda) {
return invocation.getMethod().getName().equals(LambdaSee.info(annoLambda).getMethod());
}

}
35 changes: 15 additions & 20 deletions erupt-core/src/main/java/xyz/erupt/core/proxy/EruptFieldProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,22 @@ public class EruptFieldProxy extends AnnotationProxy<EruptField, Void> {
@Override
@SneakyThrows
protected Object invocation(MethodInvocation invocation) {
switch (invocation.getMethod().getName()) {
case "views":
View[] views = this.rawAnnotation.views();
List<View> proxyViews = new ArrayList<>();
for (View view : views) {
if (ExprInvoke.getExpr(view.ifRender())) {
proxyViews.add(AnnotationProxyPool.getOrPut(view, annotation ->
new ViewProxy().newProxy(annotation, this)
));
}
}
return proxyViews.toArray(new View[0]);
case "edit":
Edit edit = this.rawAnnotation.edit();
if (ExprInvoke.getExpr(edit.ifRender())) {
return AnnotationProxyPool.getOrPut(edit, annotation ->
new EditProxy().newProxy(annotation, this)
);
} else {
return tplEruptField.edit();
if (super.matchMethod(invocation, EruptField::views)) {
View[] views = this.rawAnnotation.views();
List<View> proxyViews = new ArrayList<>();
for (View view : views) {
if (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())) {
return AnnotationProxyPool.getOrPut(edit, annotation -> new EditProxy().newProxy(annotation, this));
} else {
return tplEruptField.edit();
}
}
return this.invoke(invocation);
}
Expand Down
59 changes: 29 additions & 30 deletions erupt-core/src/main/java/xyz/erupt/core/proxy/EruptProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,37 @@ public class EruptProxy extends AnnotationProxy<Erupt, Void> {
@Override
@SneakyThrows
protected Object invocation(MethodInvocation invocation) {
switch (invocation.getMethod().getName()) {
case "filter":
Filter[] filters = this.rawAnnotation.filter();
Filter[] proxyFilters = new Filter[filters.length];
for (int i = 0; i < filters.length; i++) {
proxyFilters[i] = AnnotationProxyPool.getOrPut(filters[i], filter ->
new FilterProxy<Erupt>().newProxy(filter, this)
);
if (super.matchMethod(invocation, Erupt::filter)) {
Filter[] filters = this.rawAnnotation.filter();
Filter[] proxyFilters = new Filter[filters.length];
for (int i = 0; i < filters.length; i++) {
proxyFilters[i] = AnnotationProxyPool.getOrPut(filters[i], filter ->
new FilterProxy<Erupt>().newProxy(filter, this)
);
}
return proxyFilters;
} else if (super.matchMethod(invocation, Erupt::rowOperation)) {
RowOperation[] rowOperations = this.rawAnnotation.rowOperation();
List<RowOperation> proxyOperations = new ArrayList<>();
for (RowOperation rowOperation : rowOperations) {
if (ExprInvoke.getExpr(rowOperation.show())) {
proxyOperations.add(AnnotationProxyPool.getOrPut(rowOperation, it ->
new RowOperationProxy().newProxy(it, this)
));
}
return proxyFilters;
case "rowOperation":
RowOperation[] rowOperations = this.rawAnnotation.rowOperation();
List<RowOperation> proxyOperations = new ArrayList<>();
for (RowOperation rowOperation : rowOperations) {
if (ExprInvoke.getExpr(rowOperation.show())) {
proxyOperations.add(AnnotationProxyPool.getOrPut(rowOperation, it ->
new RowOperationProxy().newProxy(it, this)
));
}
}
return proxyOperations.toArray(new RowOperation[0]);
} else if (super.matchMethod(invocation, Erupt::drills)) {
Drill[] drills = this.rawAnnotation.drills();
List<Drill> proxyDrills = new ArrayList<>();
for (Drill drill : drills) {
if (ExprInvoke.getExpr(drill.show())) {
proxyDrills.add(AnnotationProxyPool.getOrPut(drill, it ->
new DrillProxy().newProxy(it, this)
));
}
return proxyOperations.toArray(new RowOperation[0]);
case "drills":
Drill[] drills = this.rawAnnotation.drills();
List<Drill> proxyDrills = new ArrayList<>();
for (Drill drill : drills) {
if (ExprInvoke.getExpr(drill.show())) {
proxyDrills.add(AnnotationProxyPool.getOrPut(drill, it ->
new DrillProxy().newProxy(it, this)
));
}
}
return proxyDrills.toArray(new Drill[0]);
}
return proxyDrills.toArray(new Drill[0]);
}
return this.invoke(invocation);
}
Expand Down
Loading

0 comments on commit 867c065

Please sign in to comment.