政治需求:关闭接口功能
This commit is contained in:
@@ -15,6 +15,7 @@ import { isDevelopEnv } from "../../../services/utilService";
|
||||
import { isNumber } from "underscore";
|
||||
import { redisClient } from "../../../services/redisService";
|
||||
import { checkRouteParam } from "../../../services/checkParam";
|
||||
import { isApiClose } from "../../../services/chatService";
|
||||
|
||||
export function globalFilter(app: Application) {
|
||||
return new Filter(app);
|
||||
@@ -52,7 +53,7 @@ class Filter {
|
||||
if(!this.checkFrequency(routeRecord.route, msg, roleId)) {
|
||||
return next(new Error('globalFilter'), resResult(STATUS.ACCESS_BUSY, { route: routeRecord.route }));
|
||||
}
|
||||
if(!this.checkFunction(routeRecord.route)) {
|
||||
if(!this.checkFunction(routeRecord.route, msg)) {
|
||||
return next(new Error('globalFilter'), resResult(STATUS.FUNCTION_CLOSE, { route: routeRecord.route }));
|
||||
}
|
||||
|
||||
@@ -131,11 +132,19 @@ class Filter {
|
||||
}
|
||||
|
||||
// 检查该接口是否关闭
|
||||
private checkFunction (route: string) {
|
||||
if(gameData.serverConst.API_IS_CLOSE == 1) {
|
||||
if(gameData.serverConst.CLOSE_APIS.indexOf(route) != -1) {
|
||||
private checkFunction (route: string, msg: any) {
|
||||
if(isApiClose()) {
|
||||
let isClose = gameData.serverConst.CLOSE_APIS.find(cur => {
|
||||
if(cur.route == route) {
|
||||
if(cur.param == null) return true;
|
||||
for(let key in cur.param) {
|
||||
if(cur.param[key] == true && msg[key] != undefined) return true;
|
||||
if(cur.param[key] && msg[key] == cur.param[key]) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return !isClose
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { taflush } from '../../../services/sdkService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { setWeek } from '../../../pubUtils/timeUtil';
|
||||
import { savePvpSeasonMemory } from '../../../services/log/memoryLogService';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ConnectorRemote(app);
|
||||
@@ -180,4 +181,12 @@ export class ConnectorRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user