修改状态码机制,初步改造web-server中接口返回

This commit is contained in:
liangtongchuan
2020-10-16 16:02:34 +08:00
parent c8a826466b
commit fefd2dfdd5
7 changed files with 46 additions and 34 deletions

View File

@@ -1,5 +1,4 @@
import { SERVER_NOT_FOUND } from '@consts/statusCode';
import { STATUS_SUC } from '@consts/statusCode';
import { STATUS } from '@consts/statusCode';
import { GameModel } from '@db/Game';
import { Controller } from 'egg';
@@ -9,9 +8,9 @@ export default class GameController extends Controller {
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 } };
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { serverList });
} else {
ctx.body = ctx.service.utils.exceptionResult(SERVER_NOT_FOUND);
ctx.body = ctx.service.utils.resResult(STATUS.SERVER_NOT_FOUND);
}
}
}