Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 11s
Phase 1-2: 设计文档 + 数据库 (ReadingEvent/MaterialReadingProgress/TemporaryReadingMaterial/LearningSession扩展/DailyLearningActivity扩展/LearningRecord) Phase 3: 批量上报 + 校验去重 + ReadingEventProcessorService Phase 4: 4表聚合管线 (LearningSession/MaterialReadingProgress/DailyLearningActivity/LearningRecord) Phase 5: 查询接口 (progress/continue/summary/trend/heatmap/history/reprocess) Phase 6: 权限校验 + session中断清理 + API文档 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { Controller, Get, Query } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
|
import { LearningActivityService } from './learning-activity.service';
|
|
import { GrowthService } from './growth.service';
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
import type { UserPayload } from '../../common/types';
|
|
|
|
@ApiTags('learning-activity')
|
|
@Controller('activity')
|
|
export class LearningActivityController {
|
|
constructor(
|
|
private readonly activityService: LearningActivityService,
|
|
private readonly growth: GrowthService,
|
|
) {}
|
|
|
|
@Get('heatmap')
|
|
@ApiOperation({ summary: '获取学习热力图数据' })
|
|
async getHeatmap(
|
|
@CurrentUser() user: UserPayload,
|
|
@Query('days') days?: string,
|
|
) {
|
|
const d = Math.min(Number(days ?? 365) || 365, 365);
|
|
return this.activityService.getHeatmap(String(user?.id || 'anonymous'), d);
|
|
}
|
|
|
|
@Get('summary')
|
|
@ApiOperation({ summary: '获取学习统计概览' })
|
|
async getSummary(@CurrentUser() user: UserPayload) {
|
|
return this.activityService.getSummary(String(user?.id || 'anonymous'));
|
|
}
|
|
|
|
@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));
|
|
}
|
|
|
|
@Get('streak')
|
|
@ApiOperation({ summary: '获取连续学习天数' })
|
|
async getStreak(@CurrentUser() user: UserPayload) {
|
|
return this.growth.getStreak(String(user?.id || 'anonymous'));
|
|
}
|
|
|
|
@Get('recommendations')
|
|
@ApiOperation({ summary: '获取下一步学习推荐' })
|
|
async getRecommendations(@CurrentUser() user: UserPayload) {
|
|
return this.growth.getRecommendations(String(user?.id || 'anonymous'));
|
|
}
|
|
}
|