后台:修改白名单
This commit is contained in:
+16
-8
@@ -1,22 +1,30 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { prop, DocumentType, getModelForClass } from '@typegoose/typegoose';
|
||||
import { WHITE_LIST_TYPE } from '../consts';
|
||||
|
||||
export default class WhiteList extends BaseModel {
|
||||
|
||||
@prop({ required: true, enum: WHITE_LIST_TYPE })
|
||||
type: WHITE_LIST_TYPE; // 区号
|
||||
@prop({ required: true })
|
||||
regionId: number; // 大区区号
|
||||
|
||||
@prop({ required: true })
|
||||
str: string; // ip或手机号
|
||||
env: string; // 环境变量
|
||||
|
||||
public static async checkIp(ip: string) {
|
||||
const rec: WhiteListModelType = await WhiteListModel.findOne({ type: WHITE_LIST_TYPE.IP, str: ip }).lean();
|
||||
@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 checkTel(tel: string) {
|
||||
const rec: WhiteListModelType = await WhiteListModel.findOne({ type: WHITE_LIST_TYPE.TEL, str: tel }).lean();
|
||||
public static async checkUid(env: string, serverId: number, uid: number) {
|
||||
const rec = await WhiteListModel.exists({ env, serverId, uid });
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user