Files
ZYZ/web-server/app/controller/game.ts
2020-09-13 14:02:41 +08:00

18 lines
632 B
TypeScript

import { SERVER_NOT_FOUND } from '@consts/statusCode';
import { STATUS_SUC } from '@consts/statusCode';
import { GameModel } from '@db/Game';
import { Controller } from 'egg';
export default class GameController extends Controller {
public async getServerList() {
const { ctx } = this;
const { serverType } = ctx.request.body;
const serverList: Array<any> = await GameModel.getServerListByType(serverType);
if (serverList && serverList.length > 0) {
ctx.body = { status: STATUS_SUC.code, data: { serverList } };
} else {
ctx.body = ctx.service.utils.exceptionResult(SERVER_NOT_FOUND);
}
}
}