2026-05-18 10:07:57 +08:00
|
|
|
import { Controller, Get, Query } from '@nestjs/common';
|
2026-05-09 18:25:04 +08:00
|
|
|
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
|
|
|
|
import { LearningActivityService } from './learning-activity.service';
|
2026-05-17 00:39:46 +08:00
|
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
|
|
|
import type { UserPayload } from '../../common/types';
|
2026-05-09 18:25:04 +08:00
|
|
|
|
|
|
|
|
@ApiTags('learning-activity')
|
|
|
|
|
@Controller('activity')
|
|
|
|
|
export class LearningActivityController {
|
|
|
|
|
constructor(private readonly activityService: LearningActivityService) {}
|
|
|
|
|
|
|
|
|
|
@Get('heatmap')
|
|
|
|
|
@ApiOperation({ summary: '获取学习热力图数据' })
|
2026-05-17 00:39:46 +08:00
|
|
|
async getHeatmap(@CurrentUser() user: UserPayload) {
|
|
|
|
|
return this.activityService.getHeatmap(String(user?.id || 'anonymous'));
|
2026-05-09 18:25:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('summary')
|
|
|
|
|
@ApiOperation({ summary: '获取学习统计概览' })
|
2026-05-17 00:39:46 +08:00
|
|
|
async getSummary(@CurrentUser() user: UserPayload) {
|
|
|
|
|
return this.activityService.getSummary(String(user?.id || 'anonymous'));
|
2026-05-09 18:25:04 +08:00
|
|
|
}
|
2026-05-18 10:07:57 +08:00
|
|
|
|
|
|
|
|
@Get('trend')
|
|
|
|
|
@ApiOperation({ summary: '获取 AI 学习趋势分析' })
|
|
|
|
|
async getTrend(
|
|
|
|
|
@CurrentUser() user: UserPayload,
|
|
|
|
|
@Query('days') days?: string,
|
|
|
|
|
) {
|
|
|
|
|
const periodDays = parseInt(days || '7', 10);
|
|
|
|
|
return this.activityService.getTrend(
|
|
|
|
|
String(user?.id || 'anonymous'),
|
|
|
|
|
Math.min(Math.max(periodDays, 7), 30),
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-05-09 18:25:04 +08:00
|
|
|
}
|