Files
lcbp3/backend/src/modules/ai/intent-classifier/controllers/intent-analytics.controller.ts
T
admin ea5499123e
CI / CD Pipeline / build (push) Failing after 3m57s
CI / CD Pipeline / deploy (push) Has been skipped
690519:1631 224 to 226 AI #01
2026-05-19 16:31:50 +07:00

37 lines
1.5 KiB
TypeScript

// File: src/modules/ai/intent-classifier/controllers/intent-analytics.controller.ts
// Change Log
// - 2026-05-19: สร้าง Analytics Controller สำหรับ Intent Classification (T035, US3).
import { Controller, Get, Query, UseGuards, Logger } from '@nestjs/common';
import { JwtAuthGuard } from '../../../../common/guards/jwt-auth.guard';
import { RbacGuard } from '../../../../common/guards/rbac.guard';
import { IntentAnalyticsService } from '../services/intent-analytics.service';
/**
* Analytics Controller สำหรับ Intent Classification
* Route prefix: /admin/ai/intent-analytics
* Protected by JwtAuthGuard + RbacGuard (system admin only)
*/
@Controller('admin/ai/intent-analytics')
@UseGuards(JwtAuthGuard, RbacGuard)
export class IntentAnalyticsController {
private readonly logger = new Logger(IntentAnalyticsController.name);
constructor(private readonly analyticsService: IntentAnalyticsService) {}
/**
* GET /admin/ai/intent-analytics
* ดึงสถิติ Classification ทั้งหมด
* @param from ISO date string (optional, default: 30 วันก่อน)
* @param to ISO date string (optional, default: ปัจจุบัน)
*/
@Get()
async getAnalytics(@Query('from') from?: string, @Query('to') to?: string) {
const fromDate = from ? new Date(from) : undefined;
const toDate = to ? new Date(to) : undefined;
const data = await this.analyticsService.getAnalytics(fromDate, toDate);
return { data };
}
}