创建新区时检查之前列表

This commit is contained in:
liangtongchuan
2020-12-23 18:05:51 +08:00
parent be8ae18d24
commit 5cbeaa83e9
2 changed files with 8 additions and 0 deletions

View File

@@ -22,6 +22,13 @@ export default class GameController extends Controller {
public async newServer() {
const { ctx } = this;
const { serverId, serverType, name, host, port, status } = ctx.request.body;
const serverList = await GameModel.getAllServerList();
for (let { id, host: preHost, port: prePort } of serverList) {
if (preHost === host && prePort === port && id === serverId) {
ctx.body = ctx.service.utils.resResult(STATUS.SERVER_EXISTS);
return;
}
}
const gameInfo = await GameModel.newServer(serverId, serverType, name, host, port, status);
if (gameInfo) {
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { gameInfo });