邮件,异地登录bug

This commit is contained in:
mamengke01
2021-01-09 19:07:49 +08:00
parent e22e2b168c
commit 0f04e55b34
12 changed files with 155 additions and 45 deletions

41
shared/db/Mail.ts Normal file
View File

@@ -0,0 +1,41 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { RewardInter } from '../pubUtils/interface';
import { nowSeconds } from '../pubUtils/timeUtil';
@index({ roleId: 1 })
export default class Mail extends BaseModel {
@prop({ required: true })
roleId: number;
@prop({ required: true })
seqId: number;
@prop({ required: true })
mailId: number;
@prop({ required: true })
goods: Array<RewardInter>;
@prop({ required: true, default: nowSeconds() })
sendTime: number;
@prop({ required: true })
sendName: string;
public static async addMails( mails: Array<MailType>) {
await MailModel.insertMany(mails);
}
public static async addMail(params:{ goods: Array<RewardInter>, sendName: string, mailId: number, sendTime?: number}) {
const doc = new MailModel();
const mail = Object.assign(doc.toJSON(), params);
const mailInfo: MailType = await MailModel.create(mail);
return mailInfo;
}
}
export const MailModel = getModelForClass(Mail);
export interface MailType extends Pick<DocumentType<Mail>, keyof Mail> { };