From bee68c5d8311a839725bbe1bb20216b73faa4757 Mon Sep 17 00:00:00 2001 From: jiangzeyin Date: Tue, 23 Apr 2019 12:05:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +- PLANS.md | 6 +- .../jpom/common/forward/NodeForward.java | 22 +++++- .../interceptor/PermissionInterceptor.java | 10 +-- .../user/log/UserOptLogController.java | 34 ++++++++- .../cn/keepbx/jpom/system/init/InitDb.java | 2 +- .../resources/vm/outgiving/editProject.vm | 2 +- .../src/main/resources/vm/user/log/list.vm | 76 +++++++++++++++++-- 8 files changed, 129 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0615477b..32c9f5928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ 2. 多节点统一管理(插件模式) 3. 证书解析支持cer 证书(感谢@JAVA jesion) 4. 新增记录用户操作日志[采用H2数据库](感谢@〓下页) -5. 节点分发功能 +5. 节点分发功能、合并管理项目 ### 解决BUG、优化功能 @@ -16,6 +16,7 @@ 2. 进程id解析端口、解析项目名称带缓存 3. 项目分组变更,项目列表及时刷新(感谢@〓下页) 4. 批量上传文件数量进度显示(感谢@群友) +5. linux udp端口信息解析失败(感谢@Ruby) ----------------------------------------------------------- diff --git a/PLANS.md b/PLANS.md index ab7ec9e95..2564fd733 100644 --- a/PLANS.md +++ b/PLANS.md @@ -2,9 +2,9 @@ 1. 程序宕机处理 2. 主要管理页面兼容移动端 - 3. 项目监控完善 - 4. ssl 到期提醒、快捷续签 + 3. ssl 到期提醒、快捷续签 ### 待优化解决 - 1. 支持更多压缩包 \ No newline at end of file + 1. 支持更多压缩包 + 2. 项目监控完善 \ No newline at end of file diff --git a/modules/server/src/main/java/cn/keepbx/jpom/common/forward/NodeForward.java b/modules/server/src/main/java/cn/keepbx/jpom/common/forward/NodeForward.java index 46a1bea38..fd4521ae6 100644 --- a/modules/server/src/main/java/cn/keepbx/jpom/common/forward/NodeForward.java +++ b/modules/server/src/main/java/cn/keepbx/jpom/common/forward/NodeForward.java @@ -190,21 +190,35 @@ public class NodeForward { } private static void addUser(HttpRequest httpRequest, NodeModel nodeModel) { - // 判断开启状态 - if (!nodeModel.isOpenStatus()) { - throw new JpomRuntimeException(nodeModel.getName() + "节点未启用"); - } UserModel userModel = BaseServerController.getUserModel(); addUser(httpRequest, nodeModel, userModel); } + /** + * 添加agent 授权信息header + * + * @param httpRequest request + * @param nodeModel 节点 + * @param userModel 用户 + */ public static void addUser(HttpRequest httpRequest, NodeModel nodeModel, UserModel userModel) { Objects.requireNonNull(userModel); + // 判断开启状态 + if (!nodeModel.isOpenStatus()) { + throw new JpomRuntimeException(nodeModel.getName() + "节点未启用"); + } httpRequest.header(ConfigBean.JPOM_SERVER_USER_NAME, UserModel.getOptUserName(userModel)); httpRequest.header(ConfigBean.JPOM_SERVER_SYSTEM_USER_ROLE, userModel.getUserRole(nodeModel).name()); httpRequest.header(ConfigBean.JPOM_AGENT_AUTHORIZE, nodeModel.getAuthorize(true)); } + /** + * 获取节点socket 信息 + * + * @param nodeModel 节点信息 + * @param nodeUrl url + * @return url + */ public static String getSocketUrl(NodeModel nodeModel, NodeUrl nodeUrl) { String ws; if ("https".equalsIgnoreCase(nodeModel.getProtocol())) { diff --git a/modules/server/src/main/java/cn/keepbx/jpom/common/interceptor/PermissionInterceptor.java b/modules/server/src/main/java/cn/keepbx/jpom/common/interceptor/PermissionInterceptor.java index 11a624062..05847ca01 100644 --- a/modules/server/src/main/java/cn/keepbx/jpom/common/interceptor/PermissionInterceptor.java +++ b/modules/server/src/main/java/cn/keepbx/jpom/common/interceptor/PermissionInterceptor.java @@ -12,7 +12,7 @@ import cn.keepbx.jpom.model.data.NodeModel; import cn.keepbx.jpom.model.data.UserModel; import cn.keepbx.jpom.service.manage.ProjectInfoService; import cn.keepbx.jpom.service.node.NodeService; -import cn.keepbx.jpom.system.JpomRuntimeException; +import cn.keepbx.jpom.system.AgentException; import org.springframework.http.MediaType; import org.springframework.web.method.HandlerMethod; @@ -48,7 +48,7 @@ public class PermissionInterceptor extends BaseInterceptor { // 节点信息 NodeModel nodeModel = nodeService.getItem(nodeId); if (nodeModel != null && !nodeModel.isOpenStatus()) { - throw new JpomRuntimeException(nodeModel.getName() + "节点未启用"); + throw new AgentException(nodeModel.getName() + "节点未启用"); } request.setAttribute("node", nodeModel); } @@ -61,12 +61,6 @@ public class PermissionInterceptor extends BaseInterceptor { return false; } -// ProjectInfoModel projectInfoModel = projectInfoService.getItem(val); -// if (projectInfoModel == null) { -// JsonMessage jsonMessage = new JsonMessage(300, "没有找到对应项目"); -// ServletUtil.write(response, jsonMessage.toString(), MediaType.APPLICATION_JSON_UTF8_VALUE); -// return false; -// } if (!userModel.isProject(nodeId, val)) { JsonMessage jsonMessage = new JsonMessage(300, "你没有改项目的权限"); ServletUtil.write(response, jsonMessage.toString(), MediaType.APPLICATION_JSON_UTF8_VALUE); diff --git a/modules/server/src/main/java/cn/keepbx/jpom/controller/user/log/UserOptLogController.java b/modules/server/src/main/java/cn/keepbx/jpom/controller/user/log/UserOptLogController.java index 0a80cf2c1..0ad402c1d 100644 --- a/modules/server/src/main/java/cn/keepbx/jpom/controller/user/log/UserOptLogController.java +++ b/modules/server/src/main/java/cn/keepbx/jpom/controller/user/log/UserOptLogController.java @@ -2,6 +2,10 @@ package cn.keepbx.jpom.controller.user.log; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.db.Db; import cn.hutool.db.Entity; import cn.hutool.db.Page; @@ -10,7 +14,9 @@ import cn.hutool.db.sql.Direction; import cn.hutool.db.sql.Order; import cn.jiangzeyin.common.JsonMessage; import cn.keepbx.jpom.common.BaseServerController; +import cn.keepbx.jpom.model.data.NodeModel; import cn.keepbx.jpom.model.data.UserOperateLogV1; +import cn.keepbx.jpom.service.node.NodeService; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.springframework.http.MediaType; @@ -19,7 +25,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import javax.annotation.Resource; import java.sql.SQLException; +import java.util.List; /** * 用户操作日志 @@ -30,12 +38,17 @@ import java.sql.SQLException; @Controller @RequestMapping(value = "/user/log") public class UserOptLogController extends BaseServerController { + @Resource + private NodeService nodeService; /** * 展示用户列表 */ @RequestMapping(value = "list.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE) public String projectInfo() { + // 所有节点 + List nodeModels = nodeService.list(); + setAttribute("nodeArray", nodeModels); return "user/log/list"; } @@ -45,12 +58,31 @@ public class UserOptLogController extends BaseServerController { */ @RequestMapping(value = "list_data.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody - public String listData() throws SQLException { + public String listData(String time) throws SQLException { int limit = getParameterInt("limit", 10); int page1 = getParameterInt("page", 1); Page page = new Page(page1, limit); Entity entity = Entity.create(UserOperateLogV1.TABLE_NAME); page.addOrder(new Order("optTime", Direction.DESC)); + // 时间 + if (StrUtil.isNotEmpty(time)) { + String[] val = StrUtil.split(time, "~"); + if (val.length == 2) { + DateTime startDateTime = DateUtil.parse(val[0], DatePattern.NORM_DATETIME_FORMAT); + entity.set("optTime", ">= " + startDateTime.getTime()); + + DateTime endDateTime = DateUtil.parse(val[1], DatePattern.NORM_DATETIME_FORMAT); + if (startDateTime.equals(endDateTime)) { + endDateTime = DateUtil.endOfDay(endDateTime); + } + entity.set("optTime ", "<= " + endDateTime.getTime()); + } + } + String selectNode = getParameter("selectNode"); + if (StrUtil.isNotEmpty(selectNode)) { + entity.set("nodeId ", selectNode); + } + PageResult pageResult = Db.use().page(entity, page); CopyOptions copyOptions = new CopyOptions(); copyOptions.setIgnoreError(true); diff --git a/modules/server/src/main/java/cn/keepbx/jpom/system/init/InitDb.java b/modules/server/src/main/java/cn/keepbx/jpom/system/init/InitDb.java index 3d14c3ac3..e1802fb5f 100644 --- a/modules/server/src/main/java/cn/keepbx/jpom/system/init/InitDb.java +++ b/modules/server/src/main/java/cn/keepbx/jpom/system/init/InitDb.java @@ -31,9 +31,9 @@ public class InitDb { // if (JpomManifest.getInstance().isDebug()) { setting.set("showSql", "true"); + setting.set("sqlLevel", "INFO"); setting.set("showParams", "true"); } - try { DSFactory dsFactory = DSFactory.create(setting); DSFactory.setCurrentDSFactory(dsFactory); diff --git a/modules/server/src/main/resources/vm/outgiving/editProject.vm b/modules/server/src/main/resources/vm/outgiving/editProject.vm index 294a19a8f..46b6430b4 100644 --- a/modules/server/src/main/resources/vm/outgiving/editProject.vm +++ b/modules/server/src/main/resources/vm/outgiving/editProject.vm @@ -23,7 +23,7 @@ #if(!$item)
- 创建分发项目是在不同的节点新创建对应项目(项目路径为节点白名单中的值,然后所有节点都将自动配置对应的白名单) + 创建分发项目是在不同的节点新创建对应项目(项目路径为节点白名单中的值,然后所有节点都将自动配置对应的白名单),项目id、项目名称和分发id、分发名称同步
#end diff --git a/modules/server/src/main/resources/vm/user/log/list.vm b/modules/server/src/main/resources/vm/user/log/list.vm index 51dc2ef7b..efda479cb 100644 --- a/modules/server/src/main/resources/vm/user/log/list.vm +++ b/modules/server/src/main/resources/vm/user/log/list.vm @@ -13,7 +13,7 @@
- +
+ + \ No newline at end of file