添加服务器接口

This commit is contained in:
liangtongchuan
2020-11-22 22:43:24 +08:00
parent dd9ea0dd35
commit 9d3923eccc
3 changed files with 20 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
import { STATUS } from '@consts/statusCode';
import { GameModel } from '@db/Game';
import Game, { GameModel } from '@db/Game';
import { Controller } from 'egg';
export default class GameController extends Controller {
@@ -13,4 +13,15 @@ export default class GameController extends Controller {
ctx.body = ctx.service.utils.resResult(STATUS.SERVER_NOT_FOUND);
}
}
public async newServer() {
const { ctx } = this;
const { serverId, serverType, name, host, port, status } = ctx.request.body;
const gameInfo = await GameModel.newServer(serverId, serverType, name, host, port, status);
if (gameInfo) {
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { gameInfo });
} else {
ctx.body = ctx.service.utils.resResult(STATUS.NEW_SERVER_ERR);
}
}
}