后台:添加服务器列表
This commit is contained in:
@@ -14,6 +14,12 @@ export default class GameController extends Controller {
|
||||
return
|
||||
}
|
||||
|
||||
public async getServerList() {
|
||||
const { ctx } = this;
|
||||
ctx.body = await ctx.service.game.getServerList();
|
||||
return
|
||||
}
|
||||
|
||||
public async getDicHero() {
|
||||
const { ctx } = this;
|
||||
ctx.body = await ctx.service.game.getDicHero();
|
||||
|
||||
@@ -45,6 +45,7 @@ export default (app: Application) => {
|
||||
|
||||
router.post('/api/game/getserverenv', tokenParser, controller.game.getServerEnv);
|
||||
router.post('/api/game/getserverlistbyenv', tokenParser, controller.game.getServerListByEnv);
|
||||
router.post('/api/game/getserverlist', controller.game.getServerList);
|
||||
router.post('/api/game/getdicgoods', tokenParser, controller.game.getDicGoods);
|
||||
router.post('/api/game/getdichero', tokenParser, controller.game.getDicHero);
|
||||
router.post('/api/game/getdicrmb', tokenParser, controller.game.getDicRMB);
|
||||
|
||||
@@ -38,6 +38,18 @@ export default class Game extends Service {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public async getServerList() {
|
||||
const { ctx } = this;
|
||||
const { page, pageSize, sortField, sortOrder, id, serverId, name, groupName, groupId, serverType } = ctx.request.body;
|
||||
|
||||
const list = await ServerlistModel.findByCondition(page, pageSize, sortField, sortOrder, id, serverId, name, groupName, groupId, serverType);
|
||||
const total = await ServerlistModel.countByCondition( id, serverId, name, groupName, groupId, serverType)
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
list, total
|
||||
});
|
||||
}
|
||||
|
||||
public async getDicHero() {
|
||||
let list: DicHero[] = [];
|
||||
for(let [heroId, hero] of gameData.hero) {
|
||||
|
||||
@@ -92,6 +92,40 @@ export default class Serverlist extends BaseModel {
|
||||
return server;
|
||||
}
|
||||
|
||||
public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, id: number, serverId: string|number, name: string, groupName: string, groupId: number, serverType: string) {
|
||||
|
||||
let searchObj = {};
|
||||
if (id != undefined) searchObj['id'] = id;
|
||||
if (serverId != undefined) searchObj['groupId'] = groupId;
|
||||
if (name != undefined) searchObj['name'] = name;
|
||||
if (groupName != undefined) searchObj['groupName'] = groupName;
|
||||
if (serverType != undefined) searchObj['serverType'] = serverType;
|
||||
|
||||
let sort = {};
|
||||
if(sortField && sortOrder) {
|
||||
if(sortOrder == 'ascend') {
|
||||
sort[sortField] = 1;
|
||||
} else if (sortOrder == 'descend') {
|
||||
sort[sortField] = -1;
|
||||
}
|
||||
}
|
||||
const result: ServerlistType[] = await ServerlistModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean();
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public static async countByCondition(id: number, serverId: string|number, name: string, groupName: string, groupId: number, serverType: string) {
|
||||
let searchObj = {};
|
||||
if (id != undefined) searchObj['id'] = id;
|
||||
if (serverId != undefined) searchObj['groupId'] = groupId;
|
||||
if (name != undefined) searchObj['name'] = name;
|
||||
if (groupName != undefined) searchObj['groupName'] = groupName;
|
||||
if (serverType != undefined) searchObj['serverType'] = serverType;
|
||||
|
||||
const result = await ServerlistModel.count(searchObj);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据多个活动id查询活动数据
|
||||
public static async findServerByIds(ids: number[]) {
|
||||
let result: ServerlistType[] = await ServerlistModel.find({ id: { $in: ids } }).lean();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import moment = require('moment');
|
||||
import { random } from 'underscore';
|
||||
import { REFRESH_TIME, TASK_TYPE } from '../../consts';
|
||||
import { REFRESH_TIME } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityDailyCoinModelType } from '../../db/ActivityDailyCoin';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import moment = require('moment');
|
||||
import { REFRESH_TIME, TASK_TYPE } from '../../consts';
|
||||
import { REFRESH_TIME } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityDailyMealModelType } from '../../db/ActivityDailyMeal';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
Reference in New Issue
Block a user