屏蔽:处理玩家和军团信息接口

This commit is contained in:
luying
2021-11-11 15:51:25 +08:00
parent bbb2903f12
commit 89e3dd519b
17 changed files with 261 additions and 81 deletions
+3 -3
View File
@@ -12,14 +12,14 @@ export default class SdkController extends Controller {
public async treatRoleName() {
const { ctx } = this;
const params = new RoleNameCallBackParam(ctx.request.body);
const params = new RoleNameCallBackParam(ctx.query);
ctx.body = await ctx.service.sdk.treatRoleName(params);
return;
}
public async treatGuildName() {
const { ctx } = this;
const params = new GuildNameCallBackParam(ctx.request.body);
const params = new GuildNameCallBackParam(ctx.query);
ctx.body = await ctx.service.sdk.treatGuildName(params);
return;
@@ -28,7 +28,7 @@ export default class SdkController extends Controller {
public async getGuildByUser() {
const { ctx } = this;
const params = new GetGuildInfoByUserParam(ctx.request.body);
const params = new GetGuildInfoByUserParam(ctx.query);
ctx.body = await ctx.service.sdk.getGuildByUser(params);
return;
}
+48 -3
View File
@@ -66,9 +66,7 @@ export default class Sdk extends Service {
let redisClient: RedisClient = app.context.redisClient;
let name = getRedisSubChannel(REDIS_KEY.PAY_CHANNEL, app.config.env);
console.log('**** channelname', name)
let result = await redisClient.publishAsync(name, JSON.stringify(params));
console.log('**** result', result);
if(result == 0) {
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.SERVER_IS_BUSY, '');
}
@@ -90,6 +88,7 @@ export default class Sdk extends Service {
if(!params.checkParams()) return SDK_37_TREAT_CODE.WRONG_PARAMS;
if(params.game_key != SDK_37_CONST.GAME_KEY) {
console.error('用户名或军团名违规处理, gamekey错误', params.game_key);
return SDK_37_TREAT_CODE.ERR;
}
@@ -101,6 +100,7 @@ export default class Sdk extends Service {
}
if(gameData.whiteip.indexOf(ip) == -1) {
console.error('用户名或军团名违规处理, ip限制', ip);
return SDK_37_TREAT_CODE.ERR;
}
return SDK_37_TREAT_CODE.SUCCESS
@@ -108,17 +108,63 @@ export default class Sdk extends Service {
// 用户名违规处理
public async treatRoleName(params: RoleNameCallBackParam) {
const { ctx } = this;
const { app } = ctx;
let check = this.treatRoleOrGuildNameValidate(params);
if(check.code != SDK_37_TREAT_CODE.SUCCESS.code) return check.code;
// 1. 标记这个玩家违规
let channelId = getChannelId('37', params.username);
console.log(channelId);
let user = await UserModel.findUserByChannel(channelId);
if(!user) {
console.error('用户名违规处理, 未找到玩家账号', channelId);
return SDK_37_TREAT_CODE.ERR.code;
}
let role = await RoleModel.findByUidAndSetMark(user.uid, params.sid);
if(!role) {
console.error('用户名违规处理, 未找到玩家角色', user.uid, params.sid);
return SDK_37_TREAT_CODE.ERR.code;
}
if(params.actor != role.roleName || params.actor_id != role.roleId) {
console.error('用户名违规处理, roleName或roleId对不上', params.actor, role.roleName, params.actor_id, role.roleId);
return SDK_37_TREAT_CODE.ERR.code;
}
// 2. redis发布
let redisClient: RedisClient = app.context.redisClient;
let name = getRedisSubChannel(REDIS_KEY.TREAT_ROLE_CHANNEL, app.config.env);
let result = await redisClient.publishAsync(name, role.roleId);
if(result == 0) {
console.error('用户名违规处理, 未发布到订阅频道');
return SDK_37_TREAT_CODE.ERR.code;
}
return check.code
}
// 公会信息违规处理
public async treatGuildName(params: GuildNameCallBackParam) {
const { ctx } = this;
const { app } = ctx;
let check = this.treatRoleOrGuildNameValidate(params);
if(check.code != SDK_37_TREAT_CODE.SUCCESS.code) return check.code;
// 1. 标记军团违规
let guild = await GuildModel.findByCodeAndSetMark(params.guildid, params.sid);
if(!guild) return SDK_37_TREAT_CODE.ERR.code;
// 2. redis发布
let redisClient: RedisClient = app.context.redisClient;
let name = getRedisSubChannel(REDIS_KEY.TREAT_GUILD_CHANNEL, app.config.env);
let content = JSON.stringify({ code: guild.code, serverId: params.sid, type: params.type });
let result = await redisClient.publishAsync(name, content);
if(result == 0) {
return SDK_37_TREAT_CODE.ERR.code;
}
return check.code
}
@@ -128,7 +174,6 @@ export default class Sdk extends Service {
if(check.code != SDK_37_TREAT_CODE.SUCCESS.code) return resResult(check);
let channelId = getChannelId('37', params.uid);
console.log(channelId)
let user = await UserModel.findUserByChannel(channelId);
if(!user) return resResult(SDK_37_TREAT_CODE.USER_NOT_FOUND);