后台:添加服务器列表
This commit is contained in:
@@ -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