eCourt-Doc-Edit/backend/WordVersioning.Api/Models/DocumentVersion.cs
Suphonchai Phoonsawat 39d610a781 Phase 11: version PDF (FR-15)
- เลข version ใหม่: เว็บ-generate = v0 ฉบับตั้งต้น (ไม่มี PDF), add-in save (Start Versioning + Save & Version) = v1+ มี PDF เสมอ
- PDF ผลิตจาก Word จริงผ่าน task pane เท่านั้น (getFileAsync Pdf + runtime guard, manifest ไม่เพิ่ม requirement); capture/upload เป็น best-effort — docx ผ่านแม้ PDF ล้ม + MessageBar เตือนตาม hasPdf
- Backend: DocumentVersion.PdfObjectKey (nullable, migration AddVersionPdf) + sibling .pdf ใน bucket docx-versions · multipart part pdf (ผิด type → 400) · /download + /download-link รับ ?format=pdf (ไม่มี → 404) · presigned ฝังชื่อไฟล์ไทย + _vN (RFC 5987)
- Web: เปิดไฟล์แทน blob-download — PDF แท็บใหม่, docx ผ่าน ms-word:ofe|u| พร้อม heuristic fallback ลิงก์สำรอง (useVersionOpen, versionDownload) · ปุ่ม "เปิดใน Word" ที่หน้า success ของฟอร์มสร้างเอกสาร
- Spec v7 + CONTEXT.md + ADR 0001 + แผน docs/plans/version-pdf.md
- Automated QA: backend 68 / add-in 63 / web 55 ผ่าน · manual acceptance ผ่านบน Word for Mac (2026-09-08) รวม fidelity + track changes — ค้างเฉพาะ Windows / Word on the web

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-08 14:01:13 +07:00

34 lines
1.6 KiB
C#

namespace WordVersioning.Api.Models;
/// <summary>Snapshot ของเอกสารหนึ่ง version (spec ส่วน 7)</summary>
public class DocumentVersion
{
public Guid Id { get; set; }
public Guid DocumentId { get; set; }
public Document? Document { get; set; }
/// <summary>generate เริ่ม 0; add-in เริ่ม 1 — auto increment ต่อ document (unique index กัน race)</summary>
public int VersionNumber { get; set; }
/// <summary>MinIO object key: {documentId}/v{VersionNumber:D4}_{clientVersionId}.docx</summary>
public string ObjectKey { get; set; } = string.Empty;
/// <summary>FR-15: null เมื่อไม่มี PDF (v0 หรือ capture/upload ล้ม)</summary>
public string? PdfObjectKey { get; set; }
/// <summary>SHA256 hex ของไฟล์ (ตรวจ integrity ภายหลัง)</summary>
public string ContentHash { get; set; } = string.Empty;
/// <summary>จาก claim `sub` เท่านั้น — ห้ามรับจาก client</summary>
public string CreatedByUserId { get; set; } = string.Empty;
public DateTimeOffset CreatedAt { get; set; }
/// <summary>Snapshot ค่า fields ของ version นี้ (FR-11) — map tag→text แบบ JSON</summary>
public string? FieldsSnapshotJson { get; set; }
/// <summary>คำอธิบาย version จากผู้ใช้ แบบ git commit message (FR-13) — optional ยาวสูงสุด 2048</summary>
public string? Message { get; set; }
}