Skip to content

Commit 867c065

Browse files
authored
Merge pull request #243 from erupts/develop
1.12.11
2 parents f25029d + db7deb4 commit 867c065

File tree

93 files changed

+602
-344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+602
-344
lines changed

erupt-admin/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.10</version>
12+
<version>1.12.11</version>
1313
<relativePath>../pom.xml</relativePath>
1414
</parent>
1515

erupt-annotation/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>xyz.erupt</groupId>
1313
<artifactId>erupt</artifactId>
14-
<version>1.12.10</version>
14+
<version>1.12.11</version>
1515
<relativePath>../pom.xml</relativePath>
1616
</parent>
1717
</project>

erupt-annotation/src/main/java/xyz/erupt/annotation/config/AutoFill.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
@Retention(RetentionPolicy.RUNTIME)
77
@Target(ElementType.METHOD)
88
@Documented
9+
@Deprecated
910
public @interface AutoFill {
1011

11-
@Deprecated
1212
String value();
1313

1414
}

erupt-annotation/src/main/java/xyz/erupt/annotation/constant/AnnotationConst.java

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77
public class AnnotationConst {
88

9-
public static final String VALUE = "value";
10-
119
public static final String ID = "id";
1210

1311
public static final String LABEL = "name";

erupt-annotation/src/main/java/xyz/erupt/annotation/sub_erupt/Drill.java

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package xyz.erupt.annotation.sub_erupt;
22

3-
import xyz.erupt.annotation.config.AutoFill;
43
import xyz.erupt.annotation.config.Comment;
54
import xyz.erupt.annotation.expr.ExprBool;
65

@@ -12,8 +11,6 @@
1211
*/
1312
public @interface Drill {
1413

15-
@Deprecated
16-
@AutoFill("T(Integer).toString(#item.title().hashCode())")
1714
String code() default "";
1815

1916
String title();

erupt-annotation/src/main/java/xyz/erupt/annotation/sub_erupt/RowOperation.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package xyz.erupt.annotation.sub_erupt;
22

3-
import xyz.erupt.annotation.config.AutoFill;
43
import xyz.erupt.annotation.config.Comment;
54
import xyz.erupt.annotation.expr.ExprBool;
65
import xyz.erupt.annotation.fun.OperationHandler;
@@ -15,17 +14,20 @@
1514
*/
1615
public @interface RowOperation {
1716

18-
@Deprecated
19-
@AutoFill("T(Integer).toString(#item.title().hashCode())")
2017
String code() default "";
2118

2219
String title();
2320

2421
@Transient
2522
ExprBool show() default @ExprBool;
2623

24+
@Comment("功能提示")
2725
String tip() default "";
2826

27+
@Comment("调用提示,空则不提示")
28+
String callHint() default "erupt.operation.call_hint";
29+
30+
2931
@Comment("图标请参考Font Awesome")
3032
String icon() default "fa fa-dot-circle-o";
3133

erupt-annotation/src/main/java/xyz/erupt/annotation/sub_field/ViewType.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
public enum ViewType {
1010
@Comment("根据返回值等特征自动判断")
1111
AUTO,
12-
@Comment("普通文字")
12+
@Comment("普通文文本")
1313
TEXT,
14+
@Comment("安全文本渲染")
15+
SAFE_TEXT,
1416
@Comment("图片")
1517
IMAGE,
1618
@Comment("图片BASE64")

erupt-cloud/erupt-cloud-common/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.10</version>
12+
<version>1.12.11</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-node-jpa/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.10</version>
12+
<version>1.12.11</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-node/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.10</version>
12+
<version>1.12.11</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-server/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>xyz.erupt</groupId>
1111
<artifactId>erupt</artifactId>
12-
<version>1.12.10</version>
12+
<version>1.12.11</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-server/src/main/java/xyz/erupt/cloud/server/model/CloudNode.java

+13-21
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import xyz.erupt.core.util.Erupts;
3131
import xyz.erupt.jpa.dao.EruptDao;
3232
import xyz.erupt.jpa.model.MetaModelUpdateVo;
33+
import xyz.erupt.linq.lambda.LambdaSee;
3334
import xyz.erupt.tpl.engine.EngineConst;
3435
import xyz.erupt.upms.handler.ViaMenuValueCtrl;
3536

@@ -62,13 +63,9 @@
6263
@EruptI18n
6364
public class CloudNode extends MetaModelUpdateVo implements DataProxy<CloudNode>, TagsFetchHandler, Tpl.TplHandler {
6465

65-
public static final String NODE_NAME = "nodeName";
66+
public static final String NODE_NAME = LambdaSee.field(CloudNode::getNodeName);
6667

67-
private static final String REGISTER_TYPE = "registerType";
68-
69-
private static final String ADDRESSES = "addresses";
70-
71-
public static final String ACCESS_TOKEN = "accessToken";
68+
public static final String ACCESS_TOKEN = LambdaSee.field(CloudNode::getAccessToken);
7269

7370
@Column(unique = true)
7471
@EruptField(
@@ -181,26 +178,21 @@ public void afterFetch(Collection<Map<String, Object>> list) {
181178
String token = it.toString();
182179
map.put(ACCESS_TOKEN, token.substring(0, 3) + "******" + token.substring(token.length() - 3));
183180
});
184-
String eruptNumStr = "eruptNum";
185-
String instanceNumStr = "instanceNum";
186-
String version = "version";
187-
String eruptModuleNum = "eruptModuleNum";
188-
map.put(eruptNumStr, '-');
189-
map.put(instanceNumStr, '-');
190-
map.put(version, '-');
191-
map.put(eruptModuleNum, '-');
181+
map.put(LambdaSee.field(CloudNode::getEruptNum), '-');
182+
map.put(LambdaSee.field(CloudNode::getInstanceNum), '-');
183+
map.put(LambdaSee.field(CloudNode::getVersion), '-');
184+
map.put(LambdaSee.field(CloudNode::getEruptModuleNum), '-');
192185
try {
193186
MetaNode metaNode = nodeManager.getNode(map.get(NODE_NAME).toString());
194187
Optional.ofNullable(nodeManager.getNode(map.get(NODE_NAME).toString())).ifPresent(metaNode1 -> {
195-
Function<Collection<String>, Object> function = (it) -> null == it ? 0 : String.format("<a href='javascript:alert(\"%s\");'>%d</a>",
196-
String.join("\\u000a", it), it.size());
197-
map.put(eruptNumStr, function.apply(metaNode.getErupts()));
198-
map.put(instanceNumStr, metaNode.getLocations().size());
199-
map.put(eruptModuleNum, function.apply(metaNode.getEruptModules()));
200-
map.put(version, metaNode.getVersion());
188+
Function<Collection<String>, Object> function = (it) -> null == it ? 0 : String.format("<a href='javascript:alert(`%s`);'>%d</a>", String.join("\\u000a", it), it.size());
189+
map.put(LambdaSee.field(CloudNode::getEruptNum), function.apply(metaNode.getErupts()));
190+
map.put(LambdaSee.field(CloudNode::getInstanceNum), metaNode.getLocations().size());
191+
map.put(LambdaSee.field(CloudNode::getEruptModuleNum), function.apply(metaNode.getEruptModules()));
192+
map.put(LambdaSee.field(CloudNode::getVersion), metaNode.getVersion());
201193
});
202194
} catch (Exception e) {
203-
map.put(version, String.format("<span style='color:#f00'>%s</span>", e.getMessage()));
195+
map.put(LambdaSee.field(CloudNode::getVersion), String.format("<span style='color:#f00'>%s</span>", e.getMessage()));
204196
log.warn("node warn → " + map.get(NODE_NAME), e);
205197
}
206198
}

erupt-core/pom.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>xyz.erupt</groupId>
1212
<artifactId>erupt</artifactId>
13-
<version>1.12.10</version>
13+
<version>1.12.11</version>
1414
<relativePath>../pom.xml</relativePath>
1515
</parent>
1616

@@ -52,6 +52,11 @@
5252
<artifactId>jansi</artifactId>
5353
<version>2.4.0</version>
5454
</dependency>
55+
<dependency>
56+
<groupId>${erupt.groupId}</groupId>
57+
<artifactId>linq.j</artifactId>
58+
<version>0.0.4</version>
59+
</dependency>
5560
</dependencies>
5661

5762
<build>

erupt-core/src/main/java/xyz/erupt/core/config/GsonFactory.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package xyz.erupt.core.config;
22

33
import com.google.gson.*;
4+
import lombok.Getter;
45
import xyz.erupt.core.util.DateUtil;
56

67
import java.math.BigDecimal;
@@ -14,6 +15,7 @@
1415
*/
1516
public class GsonFactory {
1617

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

33+
@Getter
3134
private static final Gson gson = gsonBuilder.create();
3235

33-
public static Gson getGson() {
34-
return gson;
35-
}
36-
37-
public static GsonBuilder getGsonBuilder() {
38-
return gsonBuilder;
39-
}
40-
4136
private GsonFactory() {
4237
}
4338
}

erupt-core/src/main/java/xyz/erupt/core/exception/EruptFieldAnnotationException.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ public static void validateEruptFieldInfo(EruptFieldModel eruptFieldModel) {
1919
switch (edit.type()) {
2020
case REFERENCE_TREE:
2121
case REFERENCE_TABLE:
22-
if (eruptFieldModel.getEruptField().views().length > 0) {
23-
for (View view : eruptFieldModel.getEruptField().views()) {
24-
if ("".equals(view.column())) {
25-
throw ExceptionAnsi.styleEruptFieldException(eruptFieldModel, "@View注解修饰复杂对象,必须配置column值 → " + view.title());
26-
}
22+
for (View view : eruptFieldModel.getEruptField().views()) {
23+
if ("".equals(view.column())) {
24+
throw ExceptionAnsi.styleEruptFieldException(eruptFieldModel, "@View注解修饰复杂对象,必须配置column值 → " + view.title());
2725
}
2826
}
2927
break;

erupt-core/src/main/java/xyz/erupt/core/proxy/AnnotationProxy.java

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import org.aopalliance.intercept.MethodInterceptor;
55
import org.aopalliance.intercept.MethodInvocation;
66
import org.springframework.aop.framework.ProxyFactory;
7+
import xyz.erupt.linq.lambda.LambdaSee;
8+
import xyz.erupt.linq.lambda.SFunction;
9+
10+
import java.lang.annotation.Annotation;
711

812
/**
913
* 注解代理
@@ -45,4 +49,8 @@ public Object invoke(MethodInvocation invocation) {
4549
return invocation.getMethod().invoke(invocation.getThis());
4650
}
4751

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

erupt-core/src/main/java/xyz/erupt/core/proxy/EruptFieldProxy.java

+15-20
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,22 @@ public class EruptFieldProxy extends AnnotationProxy<EruptField, Void> {
3232
@Override
3333
@SneakyThrows
3434
protected Object invocation(MethodInvocation invocation) {
35-
switch (invocation.getMethod().getName()) {
36-
case "views":
37-
View[] views = this.rawAnnotation.views();
38-
List<View> proxyViews = new ArrayList<>();
39-
for (View view : views) {
40-
if (ExprInvoke.getExpr(view.ifRender())) {
41-
proxyViews.add(AnnotationProxyPool.getOrPut(view, annotation ->
42-
new ViewProxy().newProxy(annotation, this)
43-
));
44-
}
45-
}
46-
return proxyViews.toArray(new View[0]);
47-
case "edit":
48-
Edit edit = this.rawAnnotation.edit();
49-
if (ExprInvoke.getExpr(edit.ifRender())) {
50-
return AnnotationProxyPool.getOrPut(edit, annotation ->
51-
new EditProxy().newProxy(annotation, this)
52-
);
53-
} else {
54-
return tplEruptField.edit();
35+
if (super.matchMethod(invocation, EruptField::views)) {
36+
View[] views = this.rawAnnotation.views();
37+
List<View> proxyViews = new ArrayList<>();
38+
for (View view : views) {
39+
if (ExprInvoke.getExpr(view.ifRender())) {
40+
proxyViews.add(AnnotationProxyPool.getOrPut(view, annotation -> new ViewProxy().newProxy(annotation, this)));
5541
}
42+
}
43+
return proxyViews.toArray(new View[0]);
44+
} else if (super.matchMethod(invocation, EruptField::edit)) {
45+
Edit edit = this.rawAnnotation.edit();
46+
if (ExprInvoke.getExpr(edit.ifRender())) {
47+
return AnnotationProxyPool.getOrPut(edit, annotation -> new EditProxy().newProxy(annotation, this));
48+
} else {
49+
return tplEruptField.edit();
50+
}
5651
}
5752
return this.invoke(invocation);
5853
}

erupt-core/src/main/java/xyz/erupt/core/proxy/EruptProxy.java

+29-30
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,37 @@ public class EruptProxy extends AnnotationProxy<Erupt, Void> {
2323
@Override
2424
@SneakyThrows
2525
protected Object invocation(MethodInvocation invocation) {
26-
switch (invocation.getMethod().getName()) {
27-
case "filter":
28-
Filter[] filters = this.rawAnnotation.filter();
29-
Filter[] proxyFilters = new Filter[filters.length];
30-
for (int i = 0; i < filters.length; i++) {
31-
proxyFilters[i] = AnnotationProxyPool.getOrPut(filters[i], filter ->
32-
new FilterProxy<Erupt>().newProxy(filter, this)
33-
);
26+
if (super.matchMethod(invocation, Erupt::filter)) {
27+
Filter[] filters = this.rawAnnotation.filter();
28+
Filter[] proxyFilters = new Filter[filters.length];
29+
for (int i = 0; i < filters.length; i++) {
30+
proxyFilters[i] = AnnotationProxyPool.getOrPut(filters[i], filter ->
31+
new FilterProxy<Erupt>().newProxy(filter, this)
32+
);
33+
}
34+
return proxyFilters;
35+
} else if (super.matchMethod(invocation, Erupt::rowOperation)) {
36+
RowOperation[] rowOperations = this.rawAnnotation.rowOperation();
37+
List<RowOperation> proxyOperations = new ArrayList<>();
38+
for (RowOperation rowOperation : rowOperations) {
39+
if (ExprInvoke.getExpr(rowOperation.show())) {
40+
proxyOperations.add(AnnotationProxyPool.getOrPut(rowOperation, it ->
41+
new RowOperationProxy().newProxy(it, this)
42+
));
3443
}
35-
return proxyFilters;
36-
case "rowOperation":
37-
RowOperation[] rowOperations = this.rawAnnotation.rowOperation();
38-
List<RowOperation> proxyOperations = new ArrayList<>();
39-
for (RowOperation rowOperation : rowOperations) {
40-
if (ExprInvoke.getExpr(rowOperation.show())) {
41-
proxyOperations.add(AnnotationProxyPool.getOrPut(rowOperation, it ->
42-
new RowOperationProxy().newProxy(it, this)
43-
));
44-
}
44+
}
45+
return proxyOperations.toArray(new RowOperation[0]);
46+
} else if (super.matchMethod(invocation, Erupt::drills)) {
47+
Drill[] drills = this.rawAnnotation.drills();
48+
List<Drill> proxyDrills = new ArrayList<>();
49+
for (Drill drill : drills) {
50+
if (ExprInvoke.getExpr(drill.show())) {
51+
proxyDrills.add(AnnotationProxyPool.getOrPut(drill, it ->
52+
new DrillProxy().newProxy(it, this)
53+
));
4554
}
46-
return proxyOperations.toArray(new RowOperation[0]);
47-
case "drills":
48-
Drill[] drills = this.rawAnnotation.drills();
49-
List<Drill> proxyDrills = new ArrayList<>();
50-
for (Drill drill : drills) {
51-
if (ExprInvoke.getExpr(drill.show())) {
52-
proxyDrills.add(AnnotationProxyPool.getOrPut(drill, it ->
53-
new DrillProxy().newProxy(it, this)
54-
));
55-
}
56-
}
57-
return proxyDrills.toArray(new Drill[0]);
55+
}
56+
return proxyDrills.toArray(new Drill[0]);
5857
}
5958
return this.invoke(invocation);
6059
}

0 commit comments

Comments
 (0)