101 lines
2.8 KiB
TypeScript
101 lines
2.8 KiB
TypeScript
import { Service } from 'egg';
|
|
import { STATUS } from '@consts';
|
|
import { GameModel } from '@db/Game';
|
|
import { ServerlistModel } from '@db/Serverlist';
|
|
import { gameData } from '@pubUtils/data';
|
|
import { DicHero } from '@pubUtils/dictionary/DicHero';
|
|
import { DicRMB } from '@pubUtils/dictionary/DicRMB';
|
|
import { DicActivityType } from '@pubUtils/dictionary/DicActivityType';
|
|
import { DicTaskType } from '@pubUtils/dictionary/DicTaskType';
|
|
|
|
/**
|
|
* 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(serverType?: string) {
|
|
const { ctx } = this;
|
|
const list = await ServerlistModel.findByServerType(serverType);
|
|
|
|
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list
|
|
});
|
|
}
|
|
|
|
|
|
public async getServerList() {
|
|
const { ctx } = this;
|
|
const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;
|
|
|
|
const list = await ServerlistModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
|
const total = await ServerlistModel.countByCondition( form )
|
|
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list, total
|
|
});
|
|
}
|
|
|
|
public async getDicHero() {
|
|
let list: DicHero[] = [];
|
|
for(let [heroId, hero] of gameData.hero) {
|
|
if(heroId <= 300) {
|
|
list.push(hero)
|
|
}
|
|
}
|
|
return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list
|
|
})
|
|
}
|
|
|
|
public async getDicGoods() {
|
|
let list = [];
|
|
for(let [_, { good_id, name, pieceId, quality, itid, image_id }] of gameData.goods) {
|
|
list.push({
|
|
good_id, name, pieceId, quality, itid, image_id
|
|
})
|
|
}
|
|
return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list
|
|
})
|
|
}
|
|
|
|
public async getDicRmb() {
|
|
let list: DicRMB[] = [];
|
|
for(let [_, dicRmb] of gameData.rmb) {
|
|
list.push(dicRmb);
|
|
}
|
|
return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list
|
|
})
|
|
}
|
|
|
|
public async getDicActivityType() {
|
|
let list: DicActivityType[] = gameData.activityType;
|
|
return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list
|
|
})
|
|
}
|
|
|
|
public async getDicTaskType() {
|
|
let list: DicTaskType[] = gameData.taskTypeDesc;
|
|
return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
|
|
list
|
|
})
|
|
}
|
|
}
|