后台:白名单

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
+1 -1
View File
@@ -712,7 +712,7 @@ export enum SERVER_STATUS {
export enum WHITE_LIST_TYPE {
IP = 1, // ip地址
TEL = 2, // 玩家手机号
UID = 2, // 玩家账号
}
// 获取道具类型
+63
View File
@@ -0,0 +1,63 @@
import BaseModel from './BaseModel';
import { prop, DocumentType, getModelForClass } from '@typegoose/typegoose';
import { WHITE_LIST_TYPE } from '../consts';
export default class RegionWhiteList extends BaseModel {
@prop({ required: true })
code: string; // 编码
@prop({ required: true })
regionId: number; // 大区区号
@prop({ required: true })
env: string; // 环境变量
@prop({ required: true, enum: WHITE_LIST_TYPE })
type: WHITE_LIST_TYPE; // 环境变量
@prop({ required: true })
ip: string; // ip
@prop({ required: true })
serverId: number; // 小区id
@prop({ required: true })
uid: number; // 玩家uid
@prop({ required: true })
roleId: string; // 玩家角色id
@prop({ required: true })
roleName: string; // 玩家角色名
public static async checkIp(env: string, ip: string) {
const rec = await WhiteListModel.exists({ env, ip });
return rec;
}
public static async checkUid(env: string, serverId: number, uid: number) {
const rec = await WhiteListModel.exists({ env, serverId, uid });
return rec;
}
public static async findByRegionId(regionId: number) {
const rec: WhiteListModelType[] = await WhiteListModel.find({ regionId });
return rec;
}
public static async updateWhiteList(code: string, params: WhiteListModelTypeParam) {
const rec: WhiteListModelType = await WhiteListModel.findOneAndUpdate({ code }, params, { new: true, upsert: true }).lean();
return rec;
}
public static async deleteWhiteList(code: string) {
const rec: WhiteListModelType = await WhiteListModel.findOneAndDelete({ code }).lean();
return rec;
}
}
export let WhiteListModel = getModelForClass(RegionWhiteList)
export interface WhiteListModelType extends Pick<DocumentType<RegionWhiteList>, keyof RegionWhiteList> { }
export type WhiteListModelTypeParam = Partial<WhiteListModelType>; // 将所有字段变成可选项
-35
View File
@@ -1,35 +0,0 @@
import BaseModel from './BaseModel';
import { prop, DocumentType, getModelForClass } from '@typegoose/typegoose';
export default class WhiteList extends BaseModel {
@prop({ required: true })
regionId: number; // 大区区号
@prop({ required: true })
env: string; // 环境变量
@prop({ required: true })
ip: string; // ip
@prop({ required: true })
serverId: number; // 小区id
@prop({ required: true })
uid: number; // 玩家uid
public static async checkIp(env: string, ip: string) {
const rec = await WhiteListModel.exists({ env, ip });
return rec;
}
public static async checkUid(env: string, serverId: number, uid: number) {
const rec = await WhiteListModel.exists({ env, serverId, uid });
return rec;
}
}
export const WhiteListModel = getModelForClass(WhiteList);
export interface WhiteListModelType extends Pick<DocumentType<WhiteList>, keyof WhiteList> { }
export type WhiteListModelTypeParam = Partial<WhiteListModelType>; // 将所有字段变成可选项
+1 -1
View File
@@ -10,7 +10,7 @@ import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE,
import { findIndex } from 'underscore';
import { getTimeFunM } from './timeUtil';
import { Floor } from '../domain/activityField/gachaField';
import { WhiteListModel } from '../db/WhiteList';
import { WhiteListModel } from '../db/RegionWhiteList';
const randomName = require("chinese-random-name");
const moment = require('moment');
const crypto = require('crypto');