feat(mining-admin): add /reports/daily endpoint for frontend reports page
Add ReportsController with /reports/daily endpoint that maps the dashboard service data to the format expected by the frontend. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
feb871bcf1
commit
13e94db450
|
|
@ -8,6 +8,7 @@ import { AuditController } from './controllers/audit.controller';
|
||||||
import { HealthController } from './controllers/health.controller';
|
import { HealthController } from './controllers/health.controller';
|
||||||
import { UsersController } from './controllers/users.controller';
|
import { UsersController } from './controllers/users.controller';
|
||||||
import { SystemAccountsController } from './controllers/system-accounts.controller';
|
import { SystemAccountsController } from './controllers/system-accounts.controller';
|
||||||
|
import { ReportsController } from './controllers/reports.controller';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ApplicationModule],
|
imports: [ApplicationModule],
|
||||||
|
|
@ -20,6 +21,7 @@ import { SystemAccountsController } from './controllers/system-accounts.controll
|
||||||
HealthController,
|
HealthController,
|
||||||
UsersController,
|
UsersController,
|
||||||
SystemAccountsController,
|
SystemAccountsController,
|
||||||
|
ReportsController,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class ApiModule {}
|
export class ApiModule {}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
import { Controller, Get, Query } from '@nestjs/common';
|
||||||
|
import {
|
||||||
|
ApiTags,
|
||||||
|
ApiOperation,
|
||||||
|
ApiBearerAuth,
|
||||||
|
ApiQuery,
|
||||||
|
} from '@nestjs/swagger';
|
||||||
|
import { DashboardService } from '../../application/services/dashboard.service';
|
||||||
|
|
||||||
|
@ApiTags('Reports')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@Controller('reports')
|
||||||
|
export class ReportsController {
|
||||||
|
constructor(private readonly dashboardService: DashboardService) {}
|
||||||
|
|
||||||
|
@Get('daily')
|
||||||
|
@ApiOperation({ summary: '获取每日报表' })
|
||||||
|
@ApiQuery({ name: 'page', required: false, type: Number })
|
||||||
|
@ApiQuery({ name: 'pageSize', required: false, type: Number })
|
||||||
|
@ApiQuery({ name: 'days', required: false, type: Number })
|
||||||
|
async getDailyReports(
|
||||||
|
@Query('page') page?: number,
|
||||||
|
@Query('pageSize') pageSize?: number,
|
||||||
|
@Query('days') days?: number,
|
||||||
|
) {
|
||||||
|
const result = await this.dashboardService.getReports(
|
||||||
|
page ?? 1,
|
||||||
|
pageSize ?? 30,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 转换为前端期望的格式
|
||||||
|
return {
|
||||||
|
items: result.data.map((report: any) => ({
|
||||||
|
id: report.id,
|
||||||
|
reportDate: report.reportDate,
|
||||||
|
totalUsers: report.users?.total || 0,
|
||||||
|
newUsers: report.users?.new || 0,
|
||||||
|
adoptedUsers: report.adoptions?.total || 0,
|
||||||
|
newAdoptedUsers: report.adoptions?.new || 0,
|
||||||
|
totalContribution: report.contribution?.total || '0',
|
||||||
|
newContribution: report.contribution?.growth || '0',
|
||||||
|
totalDistributed: report.mining?.distributed || '0',
|
||||||
|
dailyDistributed: report.mining?.distributed || '0',
|
||||||
|
totalBurned: report.mining?.burned || '0',
|
||||||
|
dailyBurned: report.mining?.burned || '0',
|
||||||
|
openPrice: report.price?.open || '1',
|
||||||
|
closePrice: report.price?.close || '1',
|
||||||
|
highPrice: report.price?.high || '1',
|
||||||
|
lowPrice: report.price?.low || '1',
|
||||||
|
totalVolume: report.trading?.volume || '0',
|
||||||
|
dailyVolume: report.trading?.volume || '0',
|
||||||
|
})),
|
||||||
|
total: result.total,
|
||||||
|
page: result.pagination.page,
|
||||||
|
pageSize: result.pagination.pageSize,
|
||||||
|
totalPages: result.pagination.totalPages,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue