84 lines
3.2 KiB
TypeScript
84 lines
3.2 KiB
TypeScript
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { CurrentSessionUserId } from '../auth/current-session-user.decorator';
|
|
import { TenantId } from '../common/tenant-id.decorator';
|
|
import { OperationsService } from './operations.service';
|
|
|
|
@ApiTags('client-operations')
|
|
@Controller('client/operations')
|
|
export class ClientOperationsController {
|
|
constructor(private readonly operations: OperationsService) {}
|
|
|
|
@Get('batch-tasks')
|
|
listBatchTasks(@TenantId() tenantId?: string, @Query('status') status?: string) {
|
|
return this.operations.listClientBatchTasks({ tenantId, status });
|
|
}
|
|
|
|
@Get('batch-tasks/:id/messages')
|
|
listTaskMessages(@TenantId() tenantId: string | undefined, @Param('id') taskId: string, @Query('phoneNumber') phoneNumber?: string) {
|
|
return this.operations.listClientMessages({ tenantId, taskId, phoneNumber });
|
|
}
|
|
|
|
@Get('messages')
|
|
listMessages(
|
|
@TenantId() tenantId?: string,
|
|
@Query('applicationId') applicationId?: string,
|
|
@Query('taskId') taskId?: string,
|
|
@Query('messageId') messageId?: string,
|
|
@Query('phoneNumber') phoneNumber?: string,
|
|
@Query('status') status?: string,
|
|
@Query('contentKeyword') contentKeyword?: string,
|
|
@Query('queuedAtFrom') queuedAtFrom?: string,
|
|
@Query('queuedAtTo') queuedAtTo?: string,
|
|
@Query('page') page?: string,
|
|
@Query('pageSize') pageSize?: string,
|
|
) {
|
|
return this.operations.listClientMessagesPage({
|
|
tenantId,
|
|
applicationId,
|
|
taskId,
|
|
messageId,
|
|
phoneNumber,
|
|
status,
|
|
contentKeyword,
|
|
queuedAtFrom,
|
|
queuedAtTo,
|
|
page: Number(page),
|
|
pageSize: Number(pageSize),
|
|
});
|
|
}
|
|
|
|
@Get('uplink-messages')
|
|
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, @Query('page') page?: string, @Query('pageSize') pageSize?: string) {
|
|
return page || pageSize
|
|
? this.operations.listUplinkMessagesPage({ tenantId, applicationId, phoneNumber, keyword, startTime, endTime, page: Number(page), pageSize: Number(pageSize) }, true)
|
|
: this.operations.listClientUplinkMessages({ tenantId, applicationId, phoneNumber, keyword, startTime, endTime });
|
|
}
|
|
|
|
@Get('dashboard')
|
|
dashboard(@TenantId() tenantId?: string) {
|
|
return this.operations.clientDashboard({ tenantId });
|
|
}
|
|
|
|
@Get('system-logs')
|
|
systemLogs(
|
|
@TenantId() tenantId?: string,
|
|
@Query('keyword') keyword?: string,
|
|
@Query('level') level?: string,
|
|
@Query('module') module?: string,
|
|
@Query('range') range?: string,
|
|
@Query('page') page?: string,
|
|
@Query('pageSize') pageSize?: string,
|
|
) {
|
|
return this.operations.systemLogs({ tenantId, keyword, level, module, range, page: Number(page), pageSize: Number(pageSize) });
|
|
}
|
|
|
|
@Post('system-logs/exports')
|
|
exportSystemLogs(
|
|
@CurrentSessionUserId() userId: string | undefined,
|
|
@Body() body: { keyword?: string; level?: string; module?: string; range?: string },
|
|
) {
|
|
return this.operations.exportSystemLogs(body, userId);
|
|
}
|
|
}
|