feat: wire admin workflows to real APIs

This commit is contained in:
hectorzhao
2026-07-02 13:50:09 +08:00
parent f8c9b78c21
commit ab421cf8a7
42 changed files with 2596 additions and 250 deletions
@@ -18,8 +18,8 @@ export class AdminSmsConfigController {
}
@Get('enterprise-templates')
listTemplates(@Query('tenantId') tenantId?: string) {
return this.smsConfig.listTemplates(tenantId);
listTemplates(@Query('tenantId') tenantId?: string, @Query('status') status?: string, @Query('keyword') keyword?: string) {
return this.smsConfig.listTemplates({ tenantId, status, keyword });
}
@Get('audit-records')
+20 -3
View File
@@ -51,6 +51,12 @@ export interface StatusChangeDto {
reason?: string;
}
export interface TemplateListQuery {
tenantId?: string;
status?: string;
keyword?: string;
}
@Injectable()
export class SmsConfigService {
constructor(private readonly prisma: PrismaService) {}
@@ -169,10 +175,21 @@ export class SmsConfigService {
return updated;
}
listTemplates(tenantId?: string) {
listTemplates(queryOrTenantId?: string | TemplateListQuery) {
const query = typeof queryOrTenantId === 'string' ? { tenantId: queryOrTenantId } : queryOrTenantId ?? {};
return this.prisma.smsTemplate.findMany({
where: tenantId ? { tenantId } : undefined,
include: { variables: true },
where: {
tenantId: query.tenantId,
auditStatus: query.status && query.status !== 'all' ? query.status : undefined,
OR: query.keyword ? [
{ name: { contains: query.keyword } },
{ content: { contains: query.keyword } },
{ category: { contains: query.keyword } },
{ application: { name: { contains: query.keyword } } },
{ tenant: { name: { contains: query.keyword } } },
] : undefined,
},
include: { variables: true, application: true, tenant: true, signature: true },
orderBy: { createdAt: 'desc' },
take: 100,
});