添加服务器增加交叉id添加方式

master
duhui 2023-01-16 15:14:59 +08:00
parent 6807f62f3e
commit 2c90177b12
4 changed files with 54 additions and 16 deletions

View File

@ -445,19 +445,32 @@ public class ServerInfoController {
int port = Integer.parseInt(vo.getPort());
int coreNum = Integer.parseInt(vo.getCoreName());
int crossGroupId = vo.getCrossGroupId();
int cross = vo.getCross();
int crossValue = 0;
for (int i = 0; i < count; i++) {
int i1 = serverId + i;
if (serverMap.get(String.valueOf(i1)) != null){
LOGGER.error("批量添加服务器出现重复id:{}",i1);
int id = serverId + i;
if (serverMap.get(String.valueOf(id)) != null){
LOGGER.error("批量添加服务器出现重复id:{}",id);
continue;
}
// 重新赋值
vo.set_id(i1);
vo.setServer_id(String.valueOf(i1));
String name = named.replace("%d", String.valueOf(nameNum + i));
vo.setName(name);
// 端口和core,不随id变化
vo.setPort(String.valueOf(port+i));
vo.setCoreName("core"+(coreNum+i));
// id和name随id变化
int i2 = i;
if (cross == 1){
id = serverId + crossValue;
i2 = crossValue;
}
vo.set_id(id);
vo.setServer_id(String.valueOf(id));
String name = named.replace("%d", String.valueOf(nameNum + i2));
vo.setName(name);
crossValue+=2;
serverInfoDao.addServerInfo(vo);
// 修改默认跨服id
RedisLogic.updateGameGroupId(vo.getServer_id(),crossGroupId);

View File

@ -71,10 +71,18 @@ public class ServerInfoVo extends ServerInfo {
/**
* 使
*
*/
@Transient
private int count;
/**
* 使
*
*/
@Transient
private int cross;
public ServerInfoVo(){
}
@ -192,6 +200,10 @@ public class ServerInfoVo extends ServerInfo {
this.count = count;
}
public int getCross() {
return cross;
}
public String getGroupShow(){
return getCrossGroupId()+"("+getOldGroupId()+")";
}

View File

@ -42,6 +42,16 @@
</div>
<div class="tabCon">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2" title="是否交叉配置服务器,默认取消" style="cursor:pointer">
<span class="c-red">* 是否交叉配置:</span>
</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="radio" name="cross" value="0" checked/> 顺位
<input type="radio" name="cross" value="1" style="margin-left: 10px"/> 交叉
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2" title="批量添加填写第一个的服务器id" style="cursor:pointer">
<span class="c-red">* serverId</span>
@ -250,6 +260,8 @@
return false;
}
var cross = $('input[name=cross]:checked').val();
$.ajax({
type: "POST",
data:
@ -271,7 +283,8 @@
"open_time":"0",
"open_type":"0",
"crossGroupId":crossId,
"count":count
"count":count,
"cross":cross
}),
url: "/addServer",
dataType: "json",

View File

@ -95,17 +95,17 @@
<!-- <span th:case="1" class="Hui-iconfont" style="color:green">开启</span>-->
<!-- </th>-->
<td class="td-manage" style="text-align: center;">
<a href="#" th:id="${obj.getServer_id()}" class="btn btn-primary radius" onclick="return editServer(this)">
<a href="#" th:id="${obj.getServer_id()}" class="btn btn-success radius" onclick="return editServer(this)">
修改
</a>
<button type="button" th:id="${obj.getServer_id()}" class="btn btn-warning radius" onclick="return deleteServer(this)">
删除
<button type="button" th:id="${obj.getServer_id()}" th:attr="status=${obj.getStatusInt()}" onclick="return restartServer(this)" class="btn btn-secondary radius">
重启
</button>
<button type="button" th:id="${obj.getServer_id()}" th:attr="status=${obj.getStatusInt()}" onclick="return restartServer(this)" class="btn btn-warning radius">
重启
<button type="button" th:id="${obj.getServer_id()}" th:attr="status=${obj.getStatusInt()}" onclick="return cleanupServer(this)" class="btn btn-warning radius">
清库
</button>
<button type="button" th:id="${obj.getServer_id()}" th:attr="status=${obj.getStatusInt()}" onclick="return cleanupServer(this)" class="btn btn-danger radius">
清库
<button type="button" th:id="${obj.getServer_id()}" class="btn btn-default radius" onclick="return deleteServer(this)">
删除
</button>
</td>
</tr>