根据用户信息下发服务器列表

This commit is contained in:
liangtongchuan
2020-11-30 21:45:00 +08:00
parent 34ec7d5b91
commit 20d638189e
3 changed files with 14 additions and 3 deletions

View File

@@ -5,8 +5,13 @@ 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);
let serverList: Array<any> = [];
let { serverType, auth } = ctx;
if (auth === 1) {
serverList = await GameModel.getAllServerList();
} else if (!auth) {
serverList = await GameModel.getServerListByType(serverType);
}
if (serverList && serverList.length > 0) {
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { serverList });
} else {