添加服务器接口
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user