后台:白名单

This commit is contained in:
luying
2021-12-08 20:45:06 +08:00
parent 46108f90f2
commit 24a9295ff3
7 changed files with 130 additions and 37 deletions
+38
View File
@@ -13,6 +13,8 @@ import { AccuseRecModel } from '@db/AccuseRec';
import { RegionModel } from '@db/Region';
import { ActivityGroupModel } from '@db/ActivityGroup';
import { nowSeconds } from '@pubUtils/timeUtil';
import { WhiteListModel } from '@db/RegionWhiteList';
import { RoleModel } from '@db/Role';
/**
* Test Service
@@ -90,6 +92,42 @@ export default class Game extends Service {
});
}
public async getWhiteList(id: number) {
const { ctx } = this;
let region = await RegionModel.findRegionById(id);
if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
let whitelist = await WhiteListModel.findByRegionId(id);
return ctx.service.utils.resResult(STATUS.SUCCESS, {
whitelist
});
}
public async updateWhiteList(id: number, code: string, type: number, content: string) {
const { ctx } = this;
let region = await RegionModel.findRegionById(id);
if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
if(type == 1) {
let whitelist = await WhiteListModel.updateWhiteList(code, { type, regionId: region.id, env: region.env, ip: content });
return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist });
} else if(type == 2) {
let role = await RoleModel.findByRoleId(content, 'roleId userInfo serverId roleName');
let whitelist = await WhiteListModel.updateWhiteList(code, { type, regionId: region.id, env: region.env, uid: role.userInfo.uid, serverId: role.serverId, roleId: role.roleId, roleName: role.roleName });
return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist });
} else {
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
}
public async deleteWhiteList(id: number, code: string) {
const { ctx } = this;
let region = await RegionModel.findRegionById(id);
if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
let whitelist = await WhiteListModel.deleteWhiteList(code);
return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist });
}
// public async getMaintenanceList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) {
// const { ctx } = this;