This commit is contained in:
xy
2026-03-13 01:38:40 +00:00
parent e6e4f88257
commit 28855885cd
311 changed files with 89544 additions and 94350 deletions

View File

@@ -11,7 +11,7 @@ const moment = require('moment');
@index({ tel: 1 })
export default class Sms extends BaseModel {
@prop({ required: true, set: (val: string) => aesEncryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV), get: (val: string) => aesDecryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV) })
@prop({ required: true, set: (val: string) => aesEncryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV), get: (val: string) => aesDecryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV) })
tel: string;
@prop({ required: true })
@@ -33,7 +33,11 @@ export default class Sms extends BaseModel {
isFixed: boolean;
public static async findByTel(tel: string, lean = true) {
console.log(4);
const sms: SmsType = await smsModel.findOne({ tel }).lean(lean);
console.log(sms);
return sms;
}
@@ -71,17 +75,19 @@ export default class Sms extends BaseModel {
public static async fixSms(tel: string) {
const sms: SmsType = await smsModel.findOneAndUpdate({ tel }, { $setOnInsert: {
tel,
code: generateNum(6),
used: false,
updateTime: new Date(),
countToday: 1
}, $set: { isFixed: true } }, {new: true, upsert: true}).lean({ getters: true });
const sms: SmsType = await smsModel.findOneAndUpdate({ tel }, {
$setOnInsert: {
tel,
code: generateNum(6),
used: false,
updateTime: new Date(),
countToday: 1
}, $set: { isFixed: true }
}, { new: true, upsert: true }).lean({ getters: true });
return sms;
}
}
export const smsModel = getModelForClass(Sms);
export interface SmsType extends Pick<DocumentType<Sms>, keyof Sms>{};
export interface SmsType extends Pick<DocumentType<Sms>, keyof Sms> { };