feat(api-ai): add usage log query endpoint

This commit is contained in:
2026-04-06 13:08:36 +08:00
parent 4578116a30
commit 5c956c195b
4 changed files with 312 additions and 7 deletions
+16 -2
View File
@@ -1,7 +1,13 @@
import { Body, Controller, Get, Headers, Post, UnauthorizedException } from "@nestjs/common";
import { Body, Controller, Get, Headers, Post, Query, UnauthorizedException } from "@nestjs/common";
import { AiChatDto } from "./dto/ai-chat.dto";
import { ListAiUsageLogsQueryDto } from "./dto/list-ai-usage-logs-query.dto";
import { UpsertAiProviderBindingDto } from "./dto/upsert-ai-provider-binding.dto";
import { AiChatResponse, AiService, ListAiBindingsResponse } from "./ai.service";
import {
AiChatResponse,
AiService,
ListAiBindingsResponse,
ListAiUsageLogsResponse
} from "./ai.service";
@Controller("ai")
export class AiController {
@@ -14,6 +20,14 @@ export class AiController {
return this.aiService.listBindings(this.resolveUserId(userIdHeader));
}
@Get("usage-logs")
async listUsageLogs(
@Headers("x-user-id") userIdHeader: string | string[] | undefined,
@Query() query: ListAiUsageLogsQueryDto
): Promise<ListAiUsageLogsResponse> {
return this.aiService.listUsageLogs(this.resolveUserId(userIdHeader), query);
}
@Post("bindings")
async upsertBinding(
@Headers("x-user-id") userIdHeader: string | string[] | undefined,