邮件,异地登录bug
This commit is contained in:
41
shared/db/Mail.ts
Normal file
41
shared/db/Mail.ts
Normal 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> { };
|
||||
Reference in New Issue
Block a user