服务器信息添加删除按钮

duhui 2021-10-29 18:19:25 +08:00
parent 4228cb9fd1
commit 5ea11c023f
8 changed files with 76 additions and 15 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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,""),

View File

@ -44,7 +44,7 @@
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
<span class="c-red">*(手动修改)</span>
serverId</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="number" name="serverId" style="width: 200px;" class="input-text"/>
@ -53,7 +53,7 @@
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
<span class="c-red">*(手动修改)</span>
服务器name</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="name" style="width: 200px;" class="input-text"/>
@ -62,7 +62,7 @@
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
<span class="c-red">*(手动修改)</span>
服务器ip</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="ip" style="width: 200px;" class="input-text"/>
@ -71,7 +71,7 @@
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
<span class="c-red">*(手动修改)</span>
服务器port</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="number" name="port" style="width: 200px;" class="input-text"/>
@ -80,8 +80,9 @@
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
channel</label>
channel<br>
<span class="c-red">*(不同渠道记得修改默认MHT渠道)</span>
</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="channel" value="MHT" style="width: 200px;" class="input-text"/>
</div>
@ -162,7 +163,7 @@
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
<span class="c-red">*(手动修改)</span>
core</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="coreName" style="width: 200px;" class="input-text"/>
@ -223,7 +224,6 @@
});
});
function addServer() {
var server_id = $("input[name='serverId']").val();
var _id = server_id;

View File

@ -92,10 +92,12 @@
<td th:text="${obj.restartTime}" style="text-align: center;"></td>
<td class="td-manage" style="text-align: center;">
<a title="" href="javascript:;"
th:href="@{/toServerInfoEdit(id =${obj.server_id},status = ${obj.status})}" class="ml-5"
style="text-decoration:none">
<span class="btn btn-primary radius">修改服务器状态</span></a>
<a href="#" class="btn btn-primary radius" th:id="${obj.server_id}" onclick="return editServer(this)">
<i class="Hui-iconfont"></i> 修改
</a>
<button type="button" th:id="${obj.server_id}" class="btn btn-danger" onclick="return deleteServer(this)">
<i class="Hui-iconfont"></i> 删除
</button>
<!--<a title="" href="javascript:;" th:href="@{/toSetOpenServerTime(id =${obj.server_id})}" class="ml-5" style="text-decoration:none">-->
<!--<span class="btn btn-primary radius">设置开服时间</span></i></a>-->
</td>
@ -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();

View File

@ -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});

View File

@ -26,8 +26,8 @@
<h1><p class="f-20 text-success">太初行管理后台</p></h1>
</div>
<div style="margin-left: 20px;font-size: 18px">
<p style="color: red">更新日志[2021-9-22]</p>
<p>1、更新道具和礼包表</p>
<p style="color: red">更新日志[2021-10-17]</p>
<p>1、服务器信息添加删除按钮</p>
</div>
<footer class="footer mt-20">
</footer>