feat(37): 根据子包信息获取大区地址的接口和后台

This commit is contained in:
liangtongchuan
2023-03-28 17:01:35 +08:00
parent ee1df7984c
commit f7344aed85
9 changed files with 212 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ import { getLocalRplUrl, getRemoteRplUrl } from 'app/pubUtils/battleUtils'
import { ChannelInfoModel } from '@db/ChannelInfo';
import { GVGVestigeRecModel } from '@db/GVGVestigeRec';
import { GVGBattleRecModel } from '@db/GVGBattleRec';
import { PackageModel } from '@db/Package';
const sendToWormhole = require('stream-wormhole');
const pump = require('mz-modules/pump');
@@ -278,4 +279,28 @@ export default class GameController extends Controller {
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { rplUrl: remoteUrl });
return;
}
// 根据 pid 和 gid 获取大区地址
public async getRegionAddr() {
const { ctx } = this;
const { pid, gid } = ctx.request.body;
if (!pid || !gid) {
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
return;
}
const pkg = await PackageModel.getPackageByGidPid(gid, pid);
if (!pkg) {
ctx.body = ctx.service.utils.resResult(STATUS.PACKAGE_NOT_FOUND);
return;
}
const { regionId } = pkg;
const region = await RegionModel.findRegionById(regionId);
if (!region) {
ctx.body = ctx.service.utils.resResult(STATUS.REGION_NOT_FOUND);
return;
}
const { webHost } = region;
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { webHost });
return;
}
}