后台:大区列表
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
import { Service } from 'egg';
|
||||
import { STATUS, MARQUEE_TYPE } from '@consts';
|
||||
import { STATUS } from '@consts';
|
||||
import { GameModel } from '@db/Game';
|
||||
import { ServerlistModel, ServerlistUpdate } from '@db/Serverlist';
|
||||
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';
|
||||
import { ServerStategyModel, ServerStategyTypeParam } from '@db/ServerStategy';
|
||||
import { NoticeModel, NoticeTypeParam, NoticeType } from '@db/Notice';
|
||||
import { MarqueeModel, MarqueeParam, MarqueeType } from '@db/Marquee';
|
||||
import { MaintenanceModel, MaintenanceTypeParam } from '@db/Maintenance';
|
||||
import { GMMailTypeParam, GMMailModel, GMMailType } from '@db/GMMail';
|
||||
import { NoticeModel, NoticeTypeParam } from '@db/Notice';
|
||||
import { MarqueeModel, MarqueeParam } from '@db/Marquee';
|
||||
import { AccuseRecModel } from '@db/AccuseRec';
|
||||
import { RegionModel } from '@db/Region';
|
||||
import { ActivityGroupModel } from '@db/ActivityGroup';
|
||||
|
||||
/**
|
||||
* Test Service
|
||||
@@ -64,106 +62,118 @@ export default class Game extends Service {
|
||||
});
|
||||
}
|
||||
|
||||
public async getMaintenanceList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) {
|
||||
public async getRegionStategy(id: number) {
|
||||
const { ctx } = this;
|
||||
let region = await RegionModel.findRegionById(id);
|
||||
if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let activityGroups = await ActivityGroupModel.findAllActivityGroup();
|
||||
|
||||
const list = await MaintenanceModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||
const total = await MaintenanceModel.countByCondition( form )
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
list: list.map(cur => {
|
||||
let marquee = <MarqueeType>cur.marquee;
|
||||
let notice = <NoticeType>cur.notice;
|
||||
return {
|
||||
...cur, startTime: cur.startTime.getTime(),
|
||||
marquee: marquee?{...marquee, startTime: marquee.startTime.getTime(), endTime: marquee.endTime.getTime()}:null,
|
||||
notice: notice?{...notice, showStartTime: notice.showStartTime.getTime(), showEndTime: notice.showEndTime.getTime()}:null
|
||||
}
|
||||
}), total
|
||||
region, activityGroups
|
||||
});
|
||||
}
|
||||
|
||||
public async updateMaintenance(values: MaintenanceTypeParam, marquee: MarqueeParam, notice: NoticeTypeParam, mail: GMMailTypeParam) {
|
||||
const { ctx } = this;
|
||||
if(values.code == 'new') {
|
||||
let serverEnv = await GameModel.getServerEnvList();
|
||||
let curEnv = serverEnv.find(cur => cur.env == this.app.config.env);
|
||||
// public async getMaintenanceList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) {
|
||||
// const { ctx } = this;
|
||||
|
||||
// const list = await MaintenanceModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||
// const total = await MaintenanceModel.countByCondition( form )
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
// list: list.map(cur => {
|
||||
// let marquee = <MarqueeType>cur.marquee;
|
||||
// let notice = <NoticeType>cur.notice;
|
||||
// return {
|
||||
// ...cur, startTime: cur.startTime.getTime(),
|
||||
// marquee: marquee?{...marquee, startTime: marquee.startTime.getTime(), endTime: marquee.endTime.getTime()}:null,
|
||||
// notice: notice?{...notice, showStartTime: notice.showStartTime.getTime(), showEndTime: notice.showEndTime.getTime()}:null
|
||||
// }
|
||||
// }), total
|
||||
// });
|
||||
// }
|
||||
|
||||
// public async updateMaintenance(values: MaintenanceTypeParam, marquee: MarqueeParam, notice: NoticeTypeParam, mail: GMMailTypeParam) {
|
||||
// const { ctx } = this;
|
||||
// if(values.code == 'new') {
|
||||
// let serverEnv = await GameModel.getServerEnvList();
|
||||
// let curEnv = serverEnv.find(cur => cur.env == this.app.config.env);
|
||||
|
||||
let marqueeResult = await MarqueeModel.createData({ ...marquee, serverIds: values.serverIds, type: MARQUEE_TYPE.SCHEDULE, isRunning: false }, ctx.user?.uid);
|
||||
let noticeResult = await NoticeModel.updateNotice('new', { ...notice, type: 1, sort: 1000, serverType: curEnv?.serverType, isEnable: false }, ctx.user?.uid);
|
||||
// let mailResult = await GMMailModel.addMail(mail, ctx.user?.uid);
|
||||
await MaintenanceModel.createData(values, marqueeResult, noticeResult, null);
|
||||
} else {
|
||||
let maintenanceResult = await MaintenanceModel.updateData(values.code, values, ctx.user?.uid);
|
||||
if(!maintenanceResult) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
let marqueeResult = <MarqueeType>maintenanceResult.marquee;
|
||||
let noticeResult = <NoticeType>maintenanceResult.notice;
|
||||
let mailResult = <GMMailType>maintenanceResult.mail;
|
||||
if(marqueeResult) await MarqueeModel.updateData(marqueeResult.code, marquee, ctx.user?.uid);
|
||||
if(noticeResult) await NoticeModel.updateNotice(noticeResult.id, notice, ctx.user?.uid);
|
||||
if(mailResult) await GMMailModel.updateMailById(mailResult._id, mail, ctx.user?.uid);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
// let marqueeResult = await MarqueeModel.createData({ ...marquee, serverIds: values.serverIds, type: MARQUEE_TYPE.SCHEDULE, isRunning: false }, ctx.user?.uid);
|
||||
// let noticeResult = await NoticeModel.updateNotice('new', { ...notice, type: 1, sort: 1000, serverType: curEnv?.serverType, isEnable: false }, ctx.user?.uid);
|
||||
// // let mailResult = await GMMailModel.addMail(mail, ctx.user?.uid);
|
||||
// await MaintenanceModel.createData(values, marqueeResult, noticeResult, null);
|
||||
// } else {
|
||||
// let maintenanceResult = await MaintenanceModel.updateData(values.code, values, ctx.user?.uid);
|
||||
// if(!maintenanceResult) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
// let marqueeResult = <MarqueeType>maintenanceResult.marquee;
|
||||
// let noticeResult = <NoticeType>maintenanceResult.notice;
|
||||
// let mailResult = <GMMailType>maintenanceResult.mail;
|
||||
// if(marqueeResult) await MarqueeModel.updateData(marqueeResult.code, marquee, ctx.user?.uid);
|
||||
// if(noticeResult) await NoticeModel.updateNotice(noticeResult.id, notice, ctx.user?.uid);
|
||||
// if(mailResult) await GMMailModel.updateMailById(mailResult._id, mail, ctx.user?.uid);
|
||||
// }
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
|
||||
public async getServerStategyList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { id?: number, name?: string }) {
|
||||
const { ctx } = this;
|
||||
// public async getServerStategyList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { id?: number, name?: string }) {
|
||||
// const { ctx } = this;
|
||||
|
||||
const list = await ServerStategyModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||
const total = await ServerStategyModel.countByCondition( form )
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
list, total
|
||||
});
|
||||
}
|
||||
// const list = await ServerStategyModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||
// const total = await ServerStategyModel.countByCondition( form )
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
// list, total
|
||||
// });
|
||||
// }
|
||||
|
||||
public async updateServerStategy(values: ServerStategyTypeParam & {id: string|number}) {
|
||||
const { ctx } = this;
|
||||
// public async updateServerStategy(values: ServerStategyTypeParam & {id: string|number}) {
|
||||
// const { ctx } = this;
|
||||
|
||||
try {
|
||||
await ServerStategyModel.updateServerStategy(values, ctx.user?.uid);
|
||||
// try {
|
||||
// await ServerStategyModel.updateServerStategy(values, ctx.user?.uid);
|
||||
|
||||
} catch(e) {
|
||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (<Error>e).stack);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
// } catch(e) {
|
||||
// return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (<Error>e).stack);
|
||||
// }
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
|
||||
public async createNewServer(name: string, openTime: number, serverType: string, stategyId: number ) {
|
||||
const { ctx } = this;
|
||||
// public async createNewServer(name: string, openTime: number, serverType: string, stategyId: number ) {
|
||||
// const { ctx } = this;
|
||||
|
||||
try {
|
||||
let stategy = await ServerStategyModel.findBySId(stategyId);
|
||||
if(!stategy) return ctx.service.utils.resResult(STATUS.GM_STATEGY_NOT_FOUND);
|
||||
// try {
|
||||
// let stategy = await ServerStategyModel.findBySId(stategyId);
|
||||
// if(!stategy) return ctx.service.utils.resResult(STATUS.GM_STATEGY_NOT_FOUND);
|
||||
|
||||
await ServerlistModel.newServer({ name, openTime: new Date(openTime), serverType }, stategy, ctx.user?.uid);
|
||||
// await ServerlistModel.newServer({ name, openTime: new Date(openTime), serverType }, stategy, ctx.user?.uid);
|
||||
|
||||
} catch(e) {
|
||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (<Error>e).stack);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
// } catch(e) {
|
||||
// return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (<Error>e).stack);
|
||||
// }
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
|
||||
public async updateServer(id: number, name: string, groupName: string, serverStatus: number ) {
|
||||
const { ctx } = this;
|
||||
// public async updateServer(id: number, name: string, groupName: string, serverStatus: number ) {
|
||||
// const { ctx } = this;
|
||||
|
||||
try {
|
||||
let server = await ServerlistModel.findByServerId(id);
|
||||
if(!server) return ctx.service.utils.resResult(STATUS.GM_SERVER_NOT_FOUND);
|
||||
// try {
|
||||
// let server = await ServerlistModel.findByServerId(id);
|
||||
// if(!server) return ctx.service.utils.resResult(STATUS.GM_SERVER_NOT_FOUND);
|
||||
|
||||
if(server.groupName != groupName) {
|
||||
await ServerlistModel.updateGroupName(server.groupId, groupName);
|
||||
}
|
||||
let update: ServerlistUpdate = {};
|
||||
if(name) update['name'] = name;
|
||||
if(groupName) update['groupName'] = groupName;
|
||||
if(serverStatus) update['serverStatus'] = serverStatus;
|
||||
// if(server.groupName != groupName) {
|
||||
// await ServerlistModel.updateGroupName(server.groupId, groupName);
|
||||
// }
|
||||
// let update: ServerlistUpdate = {};
|
||||
// if(name) update['name'] = name;
|
||||
// if(groupName) update['groupName'] = groupName;
|
||||
// if(serverStatus) update['serverStatus'] = serverStatus;
|
||||
|
||||
await ServerlistModel.updateByServerId(id, update);
|
||||
// await ServerlistModel.updateByServerId(id, update);
|
||||
|
||||
} catch(e) {
|
||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (<Error>e).stack);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
// } catch(e) {
|
||||
// return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (<Error>e).stack);
|
||||
// }
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
|
||||
public async getDicHero() {
|
||||
let list: DicHero[] = [];
|
||||
|
||||
Reference in New Issue
Block a user