修改状态码机制,初步改造web-server中接口返回
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user