feat: add HTTP API and complete client workflows

This commit is contained in:
hectorzhao
2026-07-16 11:34:06 +08:00
parent 4f07b331e5
commit dcb6162dcf
40 changed files with 2548 additions and 365 deletions
@@ -31,8 +31,8 @@ export class ClientOperationsController {
}
@Get('uplink-messages')
listUplinkMessages(@TenantId() tenantId?: string, @Query('channelId') channelId?: string) {
return this.operations.listUplinkMessages({ tenantId, channelId });
listUplinkMessages(@TenantId() tenantId?: string, @Query('channelId') channelId?: string, @Query('applicationId') applicationId?: string, @Query('phoneNumber') phoneNumber?: string, @Query('keyword') keyword?: string, @Query('startTime') startTime?: string, @Query('endTime') endTime?: string) {
return this.operations.listUplinkMessages({ tenantId, channelId, applicationId, phoneNumber, keyword, startTime, endTime });
}
@Get('dashboard')
@@ -230,7 +230,7 @@ describe('OperationsService', () => {
await service.listUplinkMessages({ tenantId: 'tenant-1', channelId: 'channel-1' });
expect(prisma.smsUplinkMessage.findMany).toHaveBeenCalledWith({
where: { tenantId: 'tenant-1', channelId: 'channel-1' },
where: { tenantId: 'tenant-1', channelId: 'channel-1', applicationId: undefined, phoneNumber: undefined, content: undefined, receivedAt: undefined },
include: {
tenant: true,
application: true,
@@ -246,6 +246,7 @@ describe('OperationsService', () => {
},
},
orderBy: { receivedAt: 'desc' },
take: 500,
});
});
+10 -2
View File
@@ -96,9 +96,16 @@ export class OperationsService {
});
}
listUplinkMessages(query: { tenantId?: string; channelId?: string }) {
listUplinkMessages(query: { tenantId?: string; channelId?: string; applicationId?: string; phoneNumber?: string; keyword?: string; startTime?: string; endTime?: string }) {
return this.prisma.smsUplinkMessage.findMany({
where: { tenantId: query.tenantId, channelId: query.channelId },
where: {
tenantId: query.tenantId,
channelId: query.channelId,
applicationId: query.applicationId,
phoneNumber: query.phoneNumber ? { contains: query.phoneNumber } : undefined,
content: query.keyword ? { contains: query.keyword } : undefined,
receivedAt: query.startTime || query.endTime ? { gte: query.startTime ? new Date(query.startTime) : undefined, lte: query.endTime ? new Date(query.endTime) : undefined } : undefined,
},
include: {
tenant: true,
application: true,
@@ -114,6 +121,7 @@ export class OperationsService {
},
},
orderBy: { receivedAt: 'desc' },
take: 500,
});
}