创建新区时检查之前列表
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user