41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { Service } from 'egg';
|
|
import { STATUS } from '@consts';
|
|
import { GameModel } from '@db/Game';
|
|
import { ServerlistModel } from '@db/Serverlist';
|
|
|
|
/**
|
|
* Test Service
|
|
*/
|
|
export default class Game extends Service {
|
|
|
|
/**
|
|
* 获取正式服,测试服,开发服等环境
|
|
*/
|
|
public async getServerEnv() {
|
|
const { ctx, app } = this;
|
|
const list = await GameModel.getServerEnvList();
|
|
|
|
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list,
|
|
env: app.config.env
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 获取正式服,测试服,开发服等环境
|
|
*/
|
|
public async getServerListByEnv() {
|
|
const { ctx, app } = this;
|
|
const envlist = await GameModel.getServerEnvList();
|
|
let cur = envlist.find(cur => cur.env == app.config.env);
|
|
if(!cur) return ctx.service.utils.resResult(STATUS.SUCCESS, { list: [] });
|
|
|
|
const list = await ServerlistModel.findByServerType(cur.serverType);
|
|
|
|
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list
|
|
});
|
|
}
|
|
|
|
}
|