Skip to content

Commit

Permalink
Merge pull request #257 from erupts/develop
Browse files Browse the repository at this point in the history
1.12.14
  • Loading branch information
erupts authored Jul 4, 2024
2 parents c121e55 + ada659e commit dedc2e9
Show file tree
Hide file tree
Showing 102 changed files with 1,742 additions and 358 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.13</version>
<version>1.12.14</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.13</version>
<version>1.12.14</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
@Comment("数据行为代理接口,对增、删、改、查等行为做逻辑处理")
Class<? extends DataProxy<?>>[] dataProxy() default {};

@Comment("此值可在dataProxy内被DataProxyContext.get()方法中获取到")
String[] dataProxyParams() default {};

@Comment("树视图配置")
Tree tree() default @Tree;

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

import xyz.erupt.annotation.config.Comment;
import xyz.erupt.annotation.fun.DataProxy;

import java.lang.annotation.*;
Expand All @@ -11,4 +12,7 @@

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

@Comment("此值可在dataProxy内被DataProxyContext.get()方法中获取到")
String[] params() default {};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package xyz.erupt.annotation.fun;

import xyz.erupt.annotation.config.Comment;

import java.util.Map;

/**
* @author YuePeng
* date 2019-07-25.
*/
public interface ChoiceTrigger {

@Comment("获取下拉列表")
@Comment("返回值会填充给key对应表单中")
Map<String, Object> trigger(Object value, String[] params);

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*/
public @interface Link {

@Comment("erupt class to associate with. Note that this class needs to be configured with access permissions")
Class<?> linkErupt();

@Transient
String column() default "id";

@Comment("erupt class to associate with. Note that this class needs to be configured with access permissions")
Class<?> linkErupt();

@Transient
@Comment("Column in linkErupt → this.column = linkErupt.joinColumn")
String joinColumn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package xyz.erupt.annotation.sub_field.sub_edit;

import xyz.erupt.annotation.config.Comment;
import xyz.erupt.annotation.config.Match;
import xyz.erupt.annotation.fun.ChoiceFetchHandler;
import xyz.erupt.annotation.fun.ChoiceTrigger;

import java.beans.Transient;

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

@Transient
@Comment("可被trigger接口获取到")
String[] triggerParams() default {};

@Comment("选择数据时触发动作")
@Match("#item.trigger().getSimpleName() != 'ChoiceTrigger'")
Class<? extends ChoiceTrigger> trigger() default ChoiceTrigger.class;

@Comment("开启后在编辑等操作时会重新获取下拉列表")
boolean anewFetch() default false;

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

enum Type {
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.13</version>
<version>1.12.14</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.13</version>
<version>1.12.14</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.13</version>
<version>1.12.14</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean getMenuCodePermission(String menuValue) {
}

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

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


}
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.13</version>
<version>1.12.14</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,9 @@ public List<MetaMenu> initMenus() {
MetaMenu nodeMenu = MetaMenu.createEruptClassMenu(CloudNode.class, nodeManager, 20);
return Arrays.asList(nodeManager,
MetaMenu.createEruptClassMenu(CloudNodeGroup.class, nodeManager, 10, MenuTypeEnum.TREE), nodeMenu,
MetaMenu.createSimpleMenu(
CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, "查看令牌",
CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, nodeMenu, 20, MenuTypeEnum.BUTTON.getCode()
),
MetaMenu.createSimpleMenu(
CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION, "节点管理",
CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION, nodeMenu, 30, MenuTypeEnum.BUTTON.getCode()
)
MetaMenu.createSimpleMenu(CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, "查看令牌", CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, nodeMenu, 110, MenuTypeEnum.BUTTON.getCode()),
MetaMenu.createSimpleMenu(CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION, "节点管理", CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION, nodeMenu, 120, MenuTypeEnum.BUTTON.getCode()),
MetaMenu.createSimpleMenu(CloudServerConst.ERUPT_CLOUD_NODE_LOG, "节点日志", CloudServerConst.ERUPT_CLOUD_NODE_LOG, nodeMenu, 120, MenuTypeEnum.BUTTON.getCode())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
*/
public class CloudServerConst {

public static final String CLOUD_ACCESS_TOKEN_PERMISSION = "cloud_access_token_permission";

//节点管理权限
public static final String CLOUD_NODE_MANAGER_PERMISSION = "cloud_node_manager_permission";

//查看 access token
public static final String CLOUD_ACCESS_TOKEN_PERMISSION = "cloud_access_token_permission";

//节点日志
public static final String ERUPT_CLOUD_NODE_LOG = "erupt_cloud_node_log";

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
package xyz.erupt.cloud.server.controller;

import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.google.gson.reflect.TypeToken;
import org.springframework.web.bind.annotation.*;
import xyz.erupt.cloud.common.consts.CloudCommonConst;
import xyz.erupt.cloud.common.consts.CloudRestApiConst;
import xyz.erupt.cloud.server.base.CloudServerConst;
import xyz.erupt.cloud.server.node.MetaNode;
import xyz.erupt.cloud.server.node.NodeManager;
import xyz.erupt.core.config.GsonFactory;
import xyz.erupt.core.constant.EruptConst;
import xyz.erupt.core.constant.EruptMutualConst;
import xyz.erupt.core.constant.EruptRestPath;
import xyz.erupt.core.exception.EruptWebApiRuntimeException;
import xyz.erupt.core.log.LogMessage;
import xyz.erupt.upms.annotation.EruptMenuAuth;
import xyz.erupt.upms.service.EruptContextService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
* @author YuePeng
Expand All @@ -19,11 +33,35 @@ public class EruptNodeController {
@Resource
private NodeManager nodeManager;

@Resource
private EruptContextService eruptContextService;

//移除实例
@GetMapping("/remove-instance/{nodeName}")
@EruptMenuAuth(CloudServerConst.CLOUD_NODE_MANAGER_PERMISSION)
public void removeInstance(@PathVariable String nodeName, @RequestParam("instance") String instance) {
nodeManager.removeNodeInstance(nodeName, instance);
}

//node节点日志
@GetMapping("/erupt-cloud-node-log")
@EruptMenuAuth(CloudServerConst.ERUPT_CLOUD_NODE_LOG)
public List<LogMessage> eruptNodeLog(@RequestParam String nodeName, @RequestParam Long size, @RequestParam(required = false) Long offset,
HttpServletResponse httpServletResponse) {
MetaNode metaNode = nodeManager.getNode(nodeName);
if (null == metaNode || metaNode.getLocations().isEmpty())
throw new EruptWebApiRuntimeException("'" + nodeName + "' node not ready");
HttpResponse httpResponse = HttpUtil.createGet(metaNode.getLocations().iterator().next() + EruptRestPath.ERUPT_TOOL + "/" + EruptConst.ERUPT_LOG)
.header(EruptMutualConst.TOKEN, eruptContextService.getCurrentToken()).header(CloudCommonConst.HEADER_ACCESS_TOKEN, metaNode.getAccessToken())
.form("size", size).form("offset", offset).execute();
if (httpResponse.getStatus() == 200) {
return GsonFactory.getGson().fromJson(httpResponse.body(), new TypeToken<List<LogMessage>>() {
}.getType()
);
} else {
httpServletResponse.setStatus(httpResponse.getStatus());
return null;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@
@Table(name = "e_cloud_node")
@Erupt(
name = "节点配置", dataProxy = CloudNodeProcess.class,
rowOperation = @RowOperation(
title = "查看令牌", icon = "fa fa-shield", mode = RowOperation.Mode.SINGLE,
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION),
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/node-info.ftl")
), layout = @Layout(tableLeftFixed = 1, pageSize = 30)
rowOperation = {
@RowOperation(
title = "查看令牌", icon = "fa fa-shield", mode = RowOperation.Mode.SINGLE,
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION),
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/node-info.ftl")
),
@RowOperation(
title = "节点日志", mode = RowOperation.Mode.SINGLE,
ifExpr = "item.version && item.version != '-'",
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.ERUPT_CLOUD_NODE_LOG),
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/erupt-log.html", width = "85%")
),
}, layout = @Layout(tableLeftFixed = 1, pageSize = 30)
)
@Component
@EruptI18n
Expand Down
9 changes: 7 additions & 2 deletions 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.13</version>
<version>1.12.14</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -55,7 +55,12 @@
<dependency>
<groupId>${erupt.groupId}</groupId>
<artifactId>linq.j</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class GsonFactory {
-> LocalDate.parse(json.getAsJsonPrimitive().getAsString(), DateTimeFormatter.ofPattern(DateUtil.DATE)))
.registerTypeAdapter(Long.class, (JsonSerializer<Long>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
.registerTypeAdapter(Double.class, (JsonSerializer<Double>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
// .registerTypeAdapter(Integer.class, (JsonSerializer<Integer>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
.registerTypeAdapter(BigDecimal.class, (JsonSerializer<BigDecimal>) (src, type, jsonSerializationContext) -> new JsonPrimitive(src.toString()))
.serializeNulls().setExclusionStrategies(new EruptGsonExclusionStrategies());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
*/
public class EruptConst {

public static final String ERUPT = "erupt";

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

public static final String ERUPT_DIR = ".erupt";

public static final String DEFAULT_DATA_PROCESSOR = "jpa";

public static final String DOT = ".";

public static final String ERUPT_LOG = "erupt-log";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
public class EruptMutualConst {

public static final String ERUPT = "erupt";
public static final String ERUPT = EruptConst.ERUPT;

public static final String USER = "user";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class EruptRestPath {
//文件
public static final String ERUPT_FILE = ERUPT_API + "/file";


//工具
public static final String ERUPT_TOOL = ERUPT_API + "/tool";

//附件虚拟路径
public static final String ERUPT_ATTACHMENT = "/erupt-attachment";

Expand Down
Loading

0 comments on commit dedc2e9

Please sign in to comment.