Skip to content

Commit

Permalink
Merge pull request #176 from erupts/develop
Browse files Browse the repository at this point in the history
1.12.0
  • Loading branch information
erupts committed Jul 9, 2023
2 parents 4f9632b + 176cb69 commit b953aaa
Show file tree
Hide file tree
Showing 2,370 changed files with 62,757 additions and 138,157 deletions.
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.11.7</version>
<version>1.12.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
@Comment("左树右表配置项")
LinkTree linkTree() default @LinkTree(field = "");

//布局配置
Layout layout() default @Layout;

// @Comment("自定义页头")
// @Match("#value.path() != ''")
// Tpl header() default @Tpl(path = "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
//表单大小
FormSize formSize() default FormSize.DEFAULT;

//表格宽度,为0则自动计算
int tableWidth() default 0;

//表格左侧固定列数量
int tableLeftFixed() default 0;

//表格右侧列固定数量
int tableRightFixed() default 0;


enum FormSize {
DEFAULT,
DEFAULT, //默认
FULL_LINE //整行
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
@Comment("导入")
boolean importable() default false;

// // 动态控制单行的编辑按钮是否展示
// String editIfExpr() default "true";
//
// // 动态控制单行删除按钮是否展示
// String deleteIfExpr() default "true";
//
// // 动态控制单行的查看详情按钮是否展示
// String viewDetailIfExpr() default "true";

@Transient
@Comment("动态处理Power权限")
Class<? extends PowerHandler> powerHandler() default PowerHandler.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@
IfExprBehavior ifExprBehavior() default IfExprBehavior.DISABLE;

@Comment("type为tpl时可用,可在模板中使用rows变量,可获取选中行的数据")
@Transient
Tpl tpl() default @Tpl(path = "");

@Comment("tpl模板弹出层宽度")
String tplWidth() default "";

@Comment("按钮提交时,需要填写的表单信息")
Class<?> eruptClass() default void.class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
public @interface Tpl {

boolean enable() default true;

@Transient
@Comment("模板文件路径")
String path();
Expand All @@ -28,8 +30,8 @@
@Comment("模板引擎")
Engine engine() default Engine.FreeMarker;

// @Comment("模板宽度")
// int width() default 0;
@Comment("弹出层宽度")
String width() default "";

@Getter
enum Engine {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
String desc() default "";

@Comment("可在模板中使用row变量,获取当前行的数据")
Tpl tpl() default @Tpl(path = "");
Tpl tpl() default @Tpl(path = "", enable = false);

@Comment("列宽度(请指定单位如:%,px)")
@Comment("列宽度(请指定单位如:%px)")
String width() default "";

@Comment("修饰类型为实体类对象时必须指定列名")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @author YuePeng
* date 2020-05-21
*/
@Deprecated
public @interface DynamicBy {

boolean enable() default true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @author YuePeng
* date 2023/5/9 22:31
*/
@Deprecated
public @interface PasswordType {

//加密次数
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.11.7</version>
<version>1.12.0-SNAPSHOT</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.11.7</version>
<version>1.12.0-SNAPSHOT</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.11.7</version>
<version>1.12.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package xyz.erupt.cloud.node.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import xyz.erupt.core.constant.EruptMutualConst;
import xyz.erupt.core.constant.EruptRestPath;
import xyz.erupt.core.service.EruptCoreService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author YuePeng
* date 2023/7/1 16:17
*/
@Configuration
@Component
public class EruptCloutNodeInterceptor implements WebMvcConfigurer, AsyncHandlerInterceptor {

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(this).addPathPatterns(EruptRestPath.ERUPT_API + "/**");
}

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String erupt = request.getHeader(EruptMutualConst.ERUPT);
if (null != erupt) {
if (null == EruptCoreService.getErupt(erupt)) {
response.setStatus(HttpStatus.NOT_FOUND.value());
return false;
}
}
return true;
}

}
7 changes: 6 additions & 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.11.7</version>
<version>1.12.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -41,6 +41,11 @@
<artifactId>erupt-tpl</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>xyz.erupt</groupId>
<artifactId>erupt-tpl-ui.ant-design</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public List<MetaMenu> initMenus() {
MetaMenu.createEruptClassMenu(CloudNodeGroup.class, nodeManager, 10, MenuTypeEnum.TREE), nodeMenu,
MetaMenu.createSimpleMenu(
CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, "查看令牌",
CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION, nodeMenu, 0, MenuTypeEnum.BUTTON.getCode()
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()
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ 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";

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public R registerNode(@RequestBody MetaNode metaNode, HttpServletRequest request
@PostMapping(CloudRestApiConst.REMOVE_INSTANCE_NODE)
public void removeInstanceNode(@RequestParam String nodeName, @RequestParam String accessToken, HttpServletRequest request) {
Optional.ofNullable(CloudServerUtil.findEruptCloudServerAnnotation()).ifPresent(it -> it.removeNode(nodeName, request));
eruptNodeMicroservice.removeInstance(nodeName, accessToken);
eruptNodeMicroservice.safeRemoveInstance(nodeName, accessToken);
}

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

import org.springframework.web.bind.annotation.*;
import xyz.erupt.cloud.common.consts.CloudRestApiConst;
import xyz.erupt.cloud.server.base.CloudServerConst;
import xyz.erupt.cloud.server.node.NodeManager;
import xyz.erupt.upms.annotation.EruptMenuAuth;

import javax.annotation.Resource;

/**
* @author YuePeng
* date 2023/6/9 22:10
*/
@RestController
@RequestMapping(CloudRestApiConst.ERUPT_CLOUD_API)
public class EruptNodeController {

@Resource
private NodeManager nodeManager;

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public String getNodeGroupConfig(@PathVariable String nodeName, @RequestHeader(C
.setParameter("accessToken", accessToken).getSingleResult();
}



//用户信息
@GetMapping(CloudRestApiConst.ERUPT_USER_INFO + "/{nodeName}")
@EruptRouter(verifyType = EruptRouter.VerifyType.LOGIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
response.sendError(HttpStatus.UNAUTHORIZED.value());
return false;
}
if (null == eruptUserService.getEruptMenuByValue(erupt)) {
response.setStatus(HttpStatus.FORBIDDEN.value());
response.sendError(HttpStatus.FORBIDDEN.value());
return false;
}
int point = erupt.lastIndexOf(".");
String nodeName = erupt.substring(0, point);
String eruptName = erupt.substring(point + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import org.springframework.stereotype.Component;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.EruptI18n;
import xyz.erupt.annotation.expr.ExprBool;
import xyz.erupt.annotation.fun.DataProxy;
import xyz.erupt.annotation.fun.TagsFetchHandler;
import xyz.erupt.annotation.sub_erupt.Layout;
import xyz.erupt.annotation.sub_erupt.RowOperation;
import xyz.erupt.annotation.sub_erupt.Tpl;
import xyz.erupt.annotation.sub_field.Edit;
Expand All @@ -22,9 +24,11 @@
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.util.Erupts;
import xyz.erupt.jpa.dao.EruptDao;
import xyz.erupt.jpa.model.MetaModelUpdateVo;
import xyz.erupt.tpl.engine.EngineConst;
import xyz.erupt.upms.handler.ViaMenuValueCtrl;

import javax.annotation.Resource;
Expand All @@ -43,15 +47,17 @@
@Setter
@Entity
@Table(name = "e_cloud_node", uniqueConstraints = @UniqueConstraint(columnNames = CloudNode.NODE_NAME))
@Erupt(name = "节点配置", dataProxy = CloudNode.class,
@Erupt(
name = "节点配置", dataProxy = CloudNode.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/NodeInfo.ftl")
)
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/node-info.ftl")
), layout = @Layout(tableLeftFixed = 1)
)
@Component
public class CloudNode extends MetaModelUpdateVo implements DataProxy<CloudNode>, TagsFetchHandler {
@EruptI18n
public class CloudNode extends MetaModelUpdateVo implements DataProxy<CloudNode>, TagsFetchHandler, Tpl.TplHandler {

public static final String NODE_NAME = "nodeName";

Expand Down Expand Up @@ -102,7 +108,9 @@ public class CloudNode extends MetaModelUpdateVo implements DataProxy<CloudNode>

@Transient
@EruptField(
views = @View(title = "实例数", className = "text-center", width = "70px")
views = @View(title = "实例数", className = "text-center", width = "70px"
, tpl = @Tpl(path = "/tpl/node-instance.ftl", width = "400px", tplHandler = CloudNode.class)
)
)
private Integer instanceNum;

Expand Down Expand Up @@ -184,7 +192,7 @@ public void afterFetch(Collection<Map<String, Object>> list) {
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, function.apply(metaNode.getLocations()));
map.put(instanceNumStr, metaNode.getLocations().size());
map.put(eruptModuleNum, function.apply(metaNode.getEruptModules()));
map.put(version, metaNode.getVersion());
});
Expand All @@ -204,4 +212,16 @@ public void afterDelete(CloudNode cloudNode) {
public List<String> fetchTags(String[] params) {
return eruptDao.getJdbcTemplate().queryForList("select name from e_upms_user", String.class);
}

@Override
public void bindTplData(Map<String, Object> binding, String[] params) {
CloudNode cloudNode = (CloudNode) binding.get(EngineConst.INJECT_ROW);
MetaNode metaNode = nodeManager.getNode(cloudNode.getNodeName());
if (null == metaNode) {
binding.put("instances", "[]");
} else {
binding.put("instances", GsonFactory.getGson().toJson(metaNode.getLocations()));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.hibernate.annotations.Type;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.EruptI18n;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
Expand All @@ -24,6 +25,7 @@
@Entity
@Table(name = "e_cloud_node_group", uniqueConstraints = @UniqueConstraint(columnNames = "code"))
@Erupt(name = "分组配置")
@EruptI18n
public class CloudNodeGroup extends MetaModel {

@EruptField(
Expand Down
Loading

0 comments on commit b953aaa

Please sign in to comment.