Skip to content

Commit dedc2e9

Browse files
authored
Merge pull request #257 from erupts/develop
1.12.14
2 parents c121e55 + ada659e commit dedc2e9

File tree

102 files changed

+1742
-358
lines changed

Some content is hidden

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

102 files changed

+1742
-358
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.13</version>
12+
<version>1.12.14</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.13</version>
14+
<version>1.12.14</version>
1515
<relativePath>../pom.xml</relativePath>
1616
</parent>
1717
</project>

erupt-annotation/src/main/java/xyz/erupt/annotation/Erupt.java

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
@Comment("数据行为代理接口,对增、删、改、查等行为做逻辑处理")
5555
Class<? extends DataProxy<?>>[] dataProxy() default {};
5656

57+
@Comment("此值可在dataProxy内被DataProxyContext.get()方法中获取到")
58+
String[] dataProxyParams() default {};
59+
5760
@Comment("树视图配置")
5861
Tree tree() default @Tree;
5962

erupt-annotation/src/main/java/xyz/erupt/annotation/PreDataProxy.java

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

3+
import xyz.erupt.annotation.config.Comment;
34
import xyz.erupt.annotation.fun.DataProxy;
45

56
import java.lang.annotation.*;
@@ -11,4 +12,7 @@
1112

1213
Class<? extends DataProxy<?>> value();
1314

15+
@Comment("此值可在dataProxy内被DataProxyContext.get()方法中获取到")
16+
String[] params() default {};
17+
1418
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package xyz.erupt.annotation.fun;
2+
3+
import xyz.erupt.annotation.config.Comment;
4+
5+
import java.util.Map;
6+
7+
/**
8+
* @author YuePeng
9+
* date 2019-07-25.
10+
*/
11+
public interface ChoiceTrigger {
12+
13+
@Comment("获取下拉列表")
14+
@Comment("返回值会填充给key对应表单中")
15+
Map<String, Object> trigger(Object value, String[] params);
16+
17+
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
*/
1111
public @interface Link {
1212

13-
@Comment("erupt class to associate with. Note that this class needs to be configured with access permissions")
14-
Class<?> linkErupt();
15-
1613
@Transient
1714
String column() default "id";
1815

16+
@Comment("erupt class to associate with. Note that this class needs to be configured with access permissions")
17+
Class<?> linkErupt();
18+
1919
@Transient
2020
@Comment("Column in linkErupt → this.column = linkErupt.joinColumn")
2121
String joinColumn();

erupt-annotation/src/main/java/xyz/erupt/annotation/sub_field/sub_edit/ChoiceType.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package xyz.erupt.annotation.sub_field.sub_edit;
22

33
import xyz.erupt.annotation.config.Comment;
4+
import xyz.erupt.annotation.config.Match;
45
import xyz.erupt.annotation.fun.ChoiceFetchHandler;
6+
import xyz.erupt.annotation.fun.ChoiceTrigger;
57

68
import java.beans.Transient;
79

@@ -25,6 +27,14 @@
2527
@Comment("动态获取选择项")
2628
Class<? extends ChoiceFetchHandler>[] fetchHandler() default {};
2729

30+
@Transient
31+
@Comment("可被trigger接口获取到")
32+
String[] triggerParams() default {};
33+
34+
@Comment("选择数据时触发动作")
35+
@Match("#item.trigger().getSimpleName() != 'ChoiceTrigger'")
36+
Class<? extends ChoiceTrigger> trigger() default ChoiceTrigger.class;
37+
2838
@Comment("开启后在编辑等操作时会重新获取下拉列表")
2939
boolean anewFetch() default false;
3040

@@ -35,7 +45,8 @@
3545
@Comment("联动过滤表达式,支持变量:")
3646
@Comment("dependValue:依赖字段的值")
3747
@Comment("vl.value: 下拉列表项的值")
38-
@Comment("vl.label: 下拉列表项中文名称")
48+
@Comment("vl.label: 下拉列表项名称")
49+
@Comment("vl.desc: 下拉列表项备注")
3950
String dependExpr() default "false";
4051

4152
enum Type {

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.13</version>
12+
<version>1.12.14</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.13</version>
12+
<version>1.12.14</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.13</version>
12+
<version>1.12.14</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-node/src/main/java/xyz/erupt/cloud/node/service/ServerRemoteService.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public boolean getMenuCodePermission(String menuValue) {
3232
}
3333

3434
public MetaUserinfo getRemoteUserInfo() {
35-
String userinfo = HttpUtil.createGet(eruptNodeProp.getBalanceAddress() + CloudRestApiConst.ERUPT_USER_INFO + eruptNodeProp.getNodeName())
35+
String userinfo = HttpUtil.createGet(eruptNodeProp.getBalanceAddress() + CloudRestApiConst.ERUPT_USER_INFO + "/" + eruptNodeProp.getNodeName())
3636
.header(EruptMutualConst.TOKEN, MetaContext.getToken())
3737
.header(CloudCommonConst.HEADER_ACCESS_TOKEN, eruptNodeProp.getAccessToken())
3838
.execute().body();
@@ -47,9 +47,10 @@ public String getNodeConfig() {
4747

4848
public String getNodeGroupConfig() {
4949
return HttpUtil.createGet(eruptNodeProp.getBalanceAddress() + CloudRestApiConst.NODE_GROUP_CONFIG + "/" + eruptNodeProp.getNodeName())
50+
// 添加请求头参数
51+
.header(CloudCommonConst.HEADER_ACCESS_TOKEN, eruptNodeProp.getAccessToken())
5052
.form(CloudCommonConst.HEADER_ACCESS_TOKEN, eruptNodeProp.getAccessToken())
5153
.execute().body();
5254
}
5355

54-
5556
}

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.13</version>
12+
<version>1.12.14</version>
1313
<relativePath>../../pom.xml</relativePath>
1414
</parent>
1515

erupt-cloud/erupt-cloud-server/src/main/java/xyz/erupt/cloud/server/EruptCloudServerAutoConfiguration.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,9 @@ public List<MetaMenu> initMenus() {
4343
MetaMenu nodeMenu = MetaMenu.createEruptClassMenu(CloudNode.class, nodeManager, 20);
4444
return Arrays.asList(nodeManager,
4545
MetaMenu.createEruptClassMenu(CloudNodeGroup.class, nodeManager, 10, MenuTypeEnum.TREE), nodeMenu,
46-
MetaMenu.createSimpleMenu(
47-
CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, "查看令牌",
48-
CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, nodeMenu, 20, MenuTypeEnum.BUTTON.getCode()
49-
),
50-
MetaMenu.createSimpleMenu(
51-
CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION, "节点管理",
52-
CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION, nodeMenu, 30, MenuTypeEnum.BUTTON.getCode()
53-
)
46+
MetaMenu.createSimpleMenu(CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, "查看令牌", CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, nodeMenu, 110, MenuTypeEnum.BUTTON.getCode()),
47+
MetaMenu.createSimpleMenu(CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION, "节点管理", CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION, nodeMenu, 120, MenuTypeEnum.BUTTON.getCode()),
48+
MetaMenu.createSimpleMenu(CloudServerConst.ERUPT_CLOUD_NODE_LOG, "节点日志", CloudServerConst.ERUPT_CLOUD_NODE_LOG, nodeMenu, 120, MenuTypeEnum.BUTTON.getCode())
5449
);
5550
}
5651

erupt-cloud/erupt-cloud-server/src/main/java/xyz/erupt/cloud/server/base/CloudServerConst.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
*/
77
public class CloudServerConst {
88

9-
public static final String CLOUD_ACCESS_TOKEN_PERMISSION = "cloud_access_token_permission";
10-
119
//节点管理权限
1210
public static final String CLOUD_NODE_MANAGER_PERMISSION = "cloud_node_manager_permission";
1311

12+
//查看 access token
13+
public static final String CLOUD_ACCESS_TOKEN_PERMISSION = "cloud_access_token_permission";
14+
15+
//节点日志
16+
public static final String ERUPT_CLOUD_NODE_LOG = "erupt_cloud_node_log";
17+
1418
}

erupt-cloud/erupt-cloud-server/src/main/java/xyz/erupt/cloud/server/controller/EruptNodeController.java

+38
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
package xyz.erupt.cloud.server.controller;
22

3+
import cn.hutool.http.HttpResponse;
4+
import cn.hutool.http.HttpUtil;
5+
import com.google.gson.reflect.TypeToken;
36
import org.springframework.web.bind.annotation.*;
7+
import xyz.erupt.cloud.common.consts.CloudCommonConst;
48
import xyz.erupt.cloud.common.consts.CloudRestApiConst;
59
import xyz.erupt.cloud.server.base.CloudServerConst;
10+
import xyz.erupt.cloud.server.node.MetaNode;
611
import xyz.erupt.cloud.server.node.NodeManager;
12+
import xyz.erupt.core.config.GsonFactory;
13+
import xyz.erupt.core.constant.EruptConst;
14+
import xyz.erupt.core.constant.EruptMutualConst;
15+
import xyz.erupt.core.constant.EruptRestPath;
16+
import xyz.erupt.core.exception.EruptWebApiRuntimeException;
17+
import xyz.erupt.core.log.LogMessage;
718
import xyz.erupt.upms.annotation.EruptMenuAuth;
19+
import xyz.erupt.upms.service.EruptContextService;
820

921
import javax.annotation.Resource;
22+
import javax.servlet.http.HttpServletResponse;
23+
import java.util.List;
1024

1125
/**
1226
* @author YuePeng
@@ -19,11 +33,35 @@ public class EruptNodeController {
1933
@Resource
2034
private NodeManager nodeManager;
2135

36+
@Resource
37+
private EruptContextService eruptContextService;
38+
2239
//移除实例
2340
@GetMapping("/remove-instance/{nodeName}")
2441
@EruptMenuAuth(CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION)
2542
public void removeInstance(@PathVariable String nodeName, @RequestParam("instance") String instance) {
2643
nodeManager.removeNodeInstance(nodeName, instance);
2744
}
2845

46+
//node节点日志
47+
@GetMapping("/erupt-cloud-node-log")
48+
@EruptMenuAuth(CloudServerConst.ERUPT_CLOUD_NODE_LOG)
49+
public List<LogMessage> eruptNodeLog(@RequestParam String nodeName, @RequestParam Long size, @RequestParam(required = false) Long offset,
50+
HttpServletResponse httpServletResponse) {
51+
MetaNode metaNode = nodeManager.getNode(nodeName);
52+
if (null == metaNode || metaNode.getLocations().isEmpty())
53+
throw new EruptWebApiRuntimeException("'" + nodeName + "' node not ready");
54+
HttpResponse httpResponse = HttpUtil.createGet(metaNode.getLocations().iterator().next() + EruptRestPath.ERUPT_TOOL + "/" + EruptConst.ERUPT_LOG)
55+
.header(EruptMutualConst.TOKEN, eruptContextService.getCurrentToken()).header(CloudCommonConst.HEADER_ACCESS_TOKEN, metaNode.getAccessToken())
56+
.form("size", size).form("offset", offset).execute();
57+
if (httpResponse.getStatus() == 200) {
58+
return GsonFactory.getGson().fromJson(httpResponse.body(), new TypeToken<List<LogMessage>>() {
59+
}.getType()
60+
);
61+
} else {
62+
httpServletResponse.setStatus(httpResponse.getStatus());
63+
return null;
64+
}
65+
}
66+
2967
}

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,19 @@
3838
@Table(name = "e_cloud_node")
3939
@Erupt(
4040
name = "节点配置", dataProxy = CloudNodeProcess.class,
41-
rowOperation = @RowOperation(
42-
title = "查看令牌", icon = "fa fa-shield", mode = RowOperation.Mode.SINGLE,
43-
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION),
44-
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/node-info.ftl")
45-
), layout = @Layout(tableLeftFixed = 1, pageSize = 30)
41+
rowOperation = {
42+
@RowOperation(
43+
title = "查看令牌", icon = "fa fa-shield", mode = RowOperation.Mode.SINGLE,
44+
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION),
45+
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/node-info.ftl")
46+
),
47+
@RowOperation(
48+
title = "节点日志", mode = RowOperation.Mode.SINGLE,
49+
ifExpr = "item.version && item.version != '-'",
50+
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.ERUPT_CLOUD_NODE_LOG),
51+
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/erupt-log.html", width = "85%")
52+
),
53+
}, layout = @Layout(tableLeftFixed = 1, pageSize = 30)
4654
)
4755
@Component
4856
@EruptI18n

erupt-core/pom.xml

+7-2
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.13</version>
13+
<version>1.12.14</version>
1414
<relativePath>../pom.xml</relativePath>
1515
</parent>
1616

@@ -55,7 +55,12 @@
5555
<dependency>
5656
<groupId>${erupt.groupId}</groupId>
5757
<artifactId>linq.j</artifactId>
58-
<version>0.0.5</version>
58+
<version>0.0.6</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-starter-log4j2</artifactId>
63+
<scope>provided</scope>
5964
</dependency>
6065
</dependencies>
6166

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

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class GsonFactory {
2727
-> LocalDate.parse(json.getAsJsonPrimitive().getAsString(), DateTimeFormatter.ofPattern(DateUtil.DATE)))
2828
.registerTypeAdapter(Long.class, (JsonSerializer<Long>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
2929
.registerTypeAdapter(Double.class, (JsonSerializer<Double>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
30+
// .registerTypeAdapter(Integer.class, (JsonSerializer<Integer>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
3031
.registerTypeAdapter(BigDecimal.class, (JsonSerializer<BigDecimal>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
3132
.serializeNulls().setExclusionStrategies(new EruptGsonExclusionStrategies());
3233

erupt-core/src/main/java/xyz/erupt/core/constant/EruptConst.java

+4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
*/
77
public class EruptConst {
88

9+
public static final String ERUPT = "erupt";
10+
911
public static final String BASE_PACKAGE = "xyz.erupt";
1012

1113
public static final String ERUPT_DIR = ".erupt";
1214

1315
public static final String DEFAULT_DATA_PROCESSOR = "jpa";
1416

1517
public static final String DOT = ".";
18+
19+
public static final String ERUPT_LOG = "erupt-log";
1620
}

erupt-core/src/main/java/xyz/erupt/core/constant/EruptMutualConst.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
public class EruptMutualConst {
99

10-
public static final String ERUPT = "erupt";
10+
public static final String ERUPT = EruptConst.ERUPT;
1111

1212
public static final String USER = "user";
1313

erupt-core/src/main/java/xyz/erupt/core/constant/EruptRestPath.java

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public class EruptRestPath {
2626
//文件
2727
public static final String ERUPT_FILE = ERUPT_API + "/file";
2828

29+
30+
//工具
31+
public static final String ERUPT_TOOL = ERUPT_API + "/tool";
32+
2933
//附件虚拟路径
3034
public static final String ERUPT_ATTACHMENT = "/erupt-attachment";
3135

0 commit comments

Comments
 (0)