260318:1401 Fix UUID #05
Build and Deploy / deploy (push) Failing after 11m8s

This commit is contained in:
admin
2026-03-18 14:01:32 +07:00
parent ba642e7e42
commit e5769269a8
37 changed files with 460 additions and 328 deletions
@@ -100,7 +100,7 @@ describe('CorrespondenceController', () => {
const mockReq = { user: { user_id: 1 } };
const result = await controller.submit(
1,
'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11',
{ note: 'Test note' },
mockReq as Parameters<typeof controller.submit>[2]
);
@@ -6,7 +6,6 @@ import {
UseGuards,
Request,
Param,
ParseIntPipe,
Query,
Delete,
Put,
@@ -43,7 +42,7 @@ export class CorrespondenceController {
private readonly workflowService: CorrespondenceWorkflowService
) {}
@Post(':id/workflow/action')
@Post(':uuid/workflow/action')
@ApiOperation({ summary: 'Process workflow action (Approve/Reject/Review)' })
@ApiResponse({ status: 201, description: 'Action processed successfully.' })
@RequirePermission('workflow.action_review')
@@ -188,15 +187,16 @@ export class CorrespondenceController {
return this.correspondenceService.addReference(corr.id, dto);
}
@Delete(':uuid/references/:targetId')
@Delete(':uuid/references/:targetUuid')
@ApiOperation({ summary: 'Remove reference' })
@ApiResponse({ status: 200, description: 'Reference removed successfully.' })
@RequirePermission('document.edit')
async removeReference(
@Param('uuid', ParseUuidPipe) uuid: string,
@Param('targetId', ParseIntPipe) targetId: number
@Param('targetUuid', ParseUuidPipe) targetUuid: string
) {
const corr = await this.correspondenceService.findOneByUuid(uuid);
return this.correspondenceService.removeReference(corr.id, targetId);
const target = await this.correspondenceService.findOneByUuid(targetUuid);
return this.correspondenceService.removeReference(corr.id, target.id);
}
}
@@ -423,8 +423,9 @@ export class CorrespondenceService {
async addReference(id: number, dto: AddReferenceDto) {
const source = await this.correspondenceRepo.findOne({ where: { id } });
// ADR-019: Resolve target UUID → internal INT id
const target = await this.correspondenceRepo.findOne({
where: { id: dto.targetId },
where: { uuid: dto.targetUuid },
});
if (!source || !target) {
@@ -438,7 +439,7 @@ export class CorrespondenceService {
const exists = await this.referenceRepo.findOne({
where: {
sourceId: id,
targetId: dto.targetId,
targetId: target.id,
},
});
@@ -448,7 +449,7 @@ export class CorrespondenceService {
const ref = this.referenceRepo.create({
sourceId: id,
targetId: dto.targetId,
targetId: target.id,
});
return this.referenceRepo.save(ref);
@@ -1,12 +1,12 @@
import { IsInt, IsNotEmpty } from 'class-validator';
import { IsUUID, IsNotEmpty } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
export class AddReferenceDto {
@ApiProperty({
description: 'Target Correspondence ID to reference',
example: 20,
description: 'Target Correspondence UUID to reference (ADR-019)',
example: '019505a1-7c3e-7000-8000-abc123def456',
})
@IsInt()
@IsUUID('all')
@IsNotEmpty()
targetId!: number;
targetUuid!: string;
}
@@ -76,7 +76,7 @@ export class CreateCorrespondenceDto {
})
@IsObject()
@IsOptional()
details?: Record<string, any>; // ข้อมูล JSON (เช่น RFI question)
details?: Record<string, unknown>; // ข้อมูล JSON (เช่น RFI question)
@ApiPropertyOptional({ description: 'Is internal document?', default: false })
@IsBoolean()
@@ -53,7 +53,7 @@ export class CorrespondenceRevision extends UuidBaseEntity {
remarks?: string;
@Column({ type: 'json', nullable: true })
details?: any; // เก็บข้อมูลแบบ Dynamic ตาม Type
details?: object; // Dynamic JSON — typed as `object` per TypeORM JSON column convention (no-any, ADR-019)
@Column({ name: 'schema_version', default: 1 })
schemaVersion!: number;