From 5ea11c023f3b4e8a290103dffc7f4648270bdc53 Mon Sep 17 00:00:00 2001 From: duhui Date: Fri, 29 Oct 2021 18:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jmfy/controller/ServerInfoController.java | 15 +++++++ src/main/java/com/jmfy/dao/ServerInfoDao.java | 2 + .../com/jmfy/dao/impl/ServerInfoDaoImpl.java | 7 +++ .../java/com/jmfy/model/vo/PowersEnum.java | 1 + src/main/resources/static/html/addServer.html | 16 +++---- .../resources/templates/findServerInfo.html | 43 +++++++++++++++++-- .../templates/permission-setting.html | 3 +- src/main/resources/templates/welcome.html | 4 +- 8 files changed, 76 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/jmfy/controller/ServerInfoController.java b/src/main/java/com/jmfy/controller/ServerInfoController.java index c294dc4..e92764b 100644 --- a/src/main/java/com/jmfy/controller/ServerInfoController.java +++ b/src/main/java/com/jmfy/controller/ServerInfoController.java @@ -99,6 +99,21 @@ public class ServerInfoController { return "serverInfoEdit"; } + @RequestMapping(value = "/deleteServer", method = {RequestMethod.POST, RequestMethod.GET}) + public @ResponseBody + int deleteServer(HttpServletRequest request) throws Exception { + boolean power = commonManager.verifyPower(request, PowersEnum.DELETE_SERVER_PERMISSIONS); + if (!power){ + return 2; + } + String serverId = request.getParameter("serverId"); + if (serverId == null){ + return 0; + } + serverInfoDao.deleteServer(serverId); + return 1; + } + /** * 修改服务器信息 * @param request diff --git a/src/main/java/com/jmfy/dao/ServerInfoDao.java b/src/main/java/com/jmfy/dao/ServerInfoDao.java index 99ce648..7e1b1a1 100644 --- a/src/main/java/com/jmfy/dao/ServerInfoDao.java +++ b/src/main/java/com/jmfy/dao/ServerInfoDao.java @@ -36,4 +36,6 @@ public interface ServerInfoDao { void addServerInfo(ServerInfo serverInfo) throws Exception; String getAllServerName(String server_Ids) throws Exception; + + void deleteServer(String serverId) throws Exception; } diff --git a/src/main/java/com/jmfy/dao/impl/ServerInfoDaoImpl.java b/src/main/java/com/jmfy/dao/impl/ServerInfoDaoImpl.java index d939831..9adb2e3 100644 --- a/src/main/java/com/jmfy/dao/impl/ServerInfoDaoImpl.java +++ b/src/main/java/com/jmfy/dao/impl/ServerInfoDaoImpl.java @@ -124,6 +124,13 @@ public class ServerInfoDaoImpl implements ServerInfoDao { return str.toString(); } + @Override + public void deleteServer(String serverId) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName); + Query query = new Query(Criteria.where("server_id").is(String.valueOf(serverId))); + mongoTemplate.remove(query,ServerInfo.class); + } + @Override public void updateOpenServerTime(CServerOpenTime cServerOpenTime,String serverId) throws Exception { MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName); diff --git a/src/main/java/com/jmfy/model/vo/PowersEnum.java b/src/main/java/com/jmfy/model/vo/PowersEnum.java index 64ac886..853b411 100644 --- a/src/main/java/com/jmfy/model/vo/PowersEnum.java +++ b/src/main/java/com/jmfy/model/vo/PowersEnum.java @@ -20,6 +20,7 @@ public enum PowersEnum { ALL_SERVER_SETTING(204,"全服配置",200,1,"serverCfgInfo"), AUTO_START_SERVER(205,"自动开服配置",200,1,"autoStartServerSetting"), AUTO_START_SERVER_PERMISSIONS(206,"权限:自动开服配置",200,0,""), + DELETE_SERVER_PERMISSIONS(207,"权限:删除服务器",200,0,""), // 序列号管理300-399 SERIAL_NUMBER_MANAGER(300,"序列号管理",300,1,""), diff --git a/src/main/resources/static/html/addServer.html b/src/main/resources/static/html/addServer.html index fa00932..1752e2d 100644 --- a/src/main/resources/static/html/addServer.html +++ b/src/main/resources/static/html/addServer.html @@ -44,7 +44,7 @@
@@ -53,7 +53,7 @@
@@ -62,7 +62,7 @@
@@ -71,7 +71,7 @@
@@ -80,8 +80,9 @@
+ channel:
+ *(不同渠道记得修改,默认MHT渠道) +
@@ -162,7 +163,7 @@
@@ -223,7 +224,6 @@ }); }); - function addServer() { var server_id = $("input[name='serverId']").val(); var _id = server_id; diff --git a/src/main/resources/templates/findServerInfo.html b/src/main/resources/templates/findServerInfo.html index aba4cfb..986338d 100644 --- a/src/main/resources/templates/findServerInfo.html +++ b/src/main/resources/templates/findServerInfo.html @@ -92,10 +92,12 @@ - - 修改服务器状态 + + 修改 + + @@ -130,6 +132,39 @@ ] }); + function editServer(obj) { + var serverId = $(obj).attr("id"); + window.location = "/toServerInfoEdit?id=" + serverId; + } + + function deleteServer(obj) { + var serverId = $(obj).attr("id"); + var msg = "请问是否要删除该服务器:{"+serverId+"},\n\n请确认!"; + if (confirm(msg) === true) { + $.ajax({ + type: "POST", + data: { + "serverId": serverId + }, + url: "/deleteServer", + success: function (data) { + if (data === 1) { + alert("操作成功"); + window.location.href = '/findServerInfo'; + } + if (data === 0) { + alert("删除失败"); + } + if (data === 2) { + alert("权限不足,无法删除!"); + } + } + }) + }else { + return false; + } + } + function updateServers() { var serverId = $("#serverId").val().toString(); var status2 = $("#status2").val().toString(); diff --git a/src/main/resources/templates/permission-setting.html b/src/main/resources/templates/permission-setting.html index fa34cf8..1a2fed2 100644 --- a/src/main/resources/templates/permission-setting.html +++ b/src/main/resources/templates/permission-setting.html @@ -128,7 +128,8 @@ url: "/updateUserPower", success: function (data) { if (data === 1) { - window.location.href = '/findMemberList' + alert("修改成功"); + window.location.href = '/findMemberList'; } if (data === 0) { layer.msg('用户不存在,修改失败!', {icon: 6, time: 1000}); diff --git a/src/main/resources/templates/welcome.html b/src/main/resources/templates/welcome.html index ecdab4c..176dd79 100644 --- a/src/main/resources/templates/welcome.html +++ b/src/main/resources/templates/welcome.html @@ -26,8 +26,8 @@

太初行管理后台

-

更新日志[2021-9-22]

-

1、更新道具和礼包表

+

更新日志[2021-10-17]

+

1、服务器信息添加删除按钮