feat(gvg): 组建期

This commit is contained in:
luying
2023-01-05 19:18:56 +08:00
parent 94c69089ac
commit 03fa74f3d1
50 changed files with 10354 additions and 38 deletions

View File

@@ -215,4 +215,16 @@ export default class GameController extends Controller {
ctx.body = await ctx.service.game.getExistHiddenData(type);
return
}
public async getGVGServerGroup() {
const { ctx } = this;
ctx.body = await ctx.service.game.getGVGServerGroup();
return
}
public async getGVGConfig() {
const { ctx } = this;
ctx.body = await ctx.service.game.getGVGConfig();
return
}
}

View File

@@ -60,6 +60,8 @@ export default (app: Application) => {
router.post('/api/game/updatechannel', controller.game.updateChannel);
router.post('/api/game/gethiddendata', controller.game.getHiddenData);
router.post('/api/game/getexisthiddendata', controller.game.getExistHiddenData);
router.post('/api/game/getgvgservergroup', controller.game.getGVGServerGroup);
router.post('/api/game/getgvgconfig', controller.game.getGVGConfig);
router.post('/api/dic/getdicgoods', tokenParser, controller.game.getDicGoods);
router.post('/api/dic/getdichero', tokenParser, controller.game.getDicHero);

View File

@@ -23,6 +23,8 @@ import { ChannelInfoModel } from '@db/ChannelInfo';
import { PVPConfigModel } from '@db/PvpConfig';
import { HiddenDataByIdModel } from '@db/HiddenDataById';
import { isNumber } from 'util';
import { GVGServerGroupModel } from '@db/GVGServerGroup';
import { GVGConfigModel } from '@db/GVGConfig';
/**
* Test Service
@@ -347,4 +349,31 @@ export default class Game extends Service {
ids: existIds
});
}
public async getGVGServerGroup() {
const { ctx } = this;
const serverlists = await ServerlistModel.findByEnv(this.app.config.realEnv);
const currentTypes = await GVGServerGroupModel.findByTime(nowSeconds());
const nextTypes = await GVGServerGroupModel.findByTime(nowSeconds() + 7 * 86400);
const servers = serverlists.map(server => {
let current = currentTypes.find(obj => obj.serverId == server.id);
let next = nextTypes.find(obj => obj.serverId == server.id);
let dic = gameData.serverNames.get(server.id);
return { id: server.id, serverId: server.serverId, name: server.name, current: current?.groupId|| dic.groupId, next: next?.groupId|| current?.groupId || dic.groupId, env: this.app.config.realEnv }
});
return ctx.service.utils.resResult(STATUS.SUCCESS, {
list: servers
});
}
public async getGVGConfig() {
const { ctx } = this;
const gvgconfig = await GVGConfigModel.findConfig();
return ctx.service.utils.resResult(STATUS.SUCCESS, {
list: gvgconfig?[{...gvgconfig, env: this.app.config.realEnv }]: []
});
}
}