35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
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>; // 将所有字段变成可选项
|