系统:停服维护逻辑
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { getModelForClass, prop, DocumentType } 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 })
|
||||
str: string; // ip或手机号
|
||||
|
||||
public static async checkIp(ip: string) {
|
||||
const rec: WhiteListModelType = await WhiteListModel.findOne({ type: WHITE_LIST_TYPE.IP, str: ip }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async checkTel(tel: string) {
|
||||
const rec: WhiteListModelType = await WhiteListModel.findOne({ type: WHITE_LIST_TYPE.TEL, str: tel }).lean();
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
export const WhiteListModel = getModelForClass(WhiteList);
|
||||
|
||||
export interface WhiteListModelType extends Pick<DocumentType<WhiteList>, keyof WhiteList> { }
|
||||
export type WhiteListModelTypeParam = Partial<WhiteListModelType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user