690524:1919 ADR-028-228-migration #04
CI / CD Pipeline / build (push) Successful in 4m10s
CI / CD Pipeline / deploy (push) Successful in 3m52s

This commit is contained in:
2026-05-24 19:19:46 +07:00
parent 93fd95a6b3
commit 1564f8648d
22 changed files with 1422 additions and 255 deletions
@@ -1,6 +1,7 @@
// File: src/modules/ai/ai-migration-checkpoint.service.ts
// Change Log:
// - 2026-05-23: สร้าง service จัดการ Migration Checkpoint, Queue และ Error log ผ่าน API (ADR-023A)
// - 2026-05-24: เพิ่มฟังก์ชันค้นหาและแปลง UUID เป็นตัวเลข ID จริงใน upsertQueueRecord เพื่อป้องกันการเขียนทับด้วย undefined
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
@@ -102,7 +103,19 @@ export class AiMigrationCheckpointService {
record.batchId = dto.batchId;
record.originalFileName = dto.documentNumber;
record.tempAttachmentId = dto.tempAttachmentId ?? undefined;
if (dto.tempAttachmentId) {
if (typeof dto.tempAttachmentId === 'number') {
record.tempAttachmentId = dto.tempAttachmentId;
} else {
const rows = await this.dataSource.manager.query<{ id: number }[]>(
'SELECT id FROM attachments WHERE uuid = ? LIMIT 1',
[dto.tempAttachmentId]
);
if (rows && rows.length > 0) {
record.tempAttachmentId = rows[0].id;
}
}
}
record.confidenceScore = dto.confidence ?? undefined;
record.status =
dto.status === 'PENDING_REVIEW'
@@ -1,6 +1,7 @@
// File: src/modules/ai/dto/migration-checkpoint.dto.ts
// Change Log:
// - 2026-05-23: สร้าง DTOs สำหรับ Migration Checkpoint API endpoints (ADR-023A)
// - 2026-05-24: ปรับปรุงประเภทข้อมูล tempAttachmentId ใน MigrationQueueRecordDto ให้รับได้ทั้ง string (UUID) และ number
import {
IsEnum,
@@ -47,9 +48,8 @@ export class MigrationQueueRecordDto {
@IsOptional()
originalSubject?: string;
@IsNumber()
@IsOptional()
tempAttachmentId?: number;
tempAttachmentId?: string | number;
@IsNumber()
@Min(0)