webadmin系统设置
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import type { MockSmsCodeItem } from '@dukang/shared-types';
|
||||
import { PrismaService } from '../prisma/prisma.module';
|
||||
|
||||
const LIST_LIMIT = 50;
|
||||
|
||||
@Injectable()
|
||||
export class MockSmsCodeService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async record(phone: string, scene: string, code: string) {
|
||||
await this.prisma.mockSmsCode.create({
|
||||
data: { phone, scene, code },
|
||||
});
|
||||
}
|
||||
|
||||
async listRecent(limit = LIST_LIMIT): Promise<MockSmsCodeItem[]> {
|
||||
const rows = await this.prisma.mockSmsCode.findMany({
|
||||
orderBy: { createdAt: 'desc' },
|
||||
take: limit,
|
||||
});
|
||||
return rows.map((row) => ({
|
||||
id: String(row.id),
|
||||
phone: row.phone,
|
||||
scene: row.scene,
|
||||
code: row.code,
|
||||
createdAt: row.createdAt.toISOString(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user