implement Phase 1-2
This commit is contained in:
parent
41573b3c4f
commit
b976cf3124
23 changed files with 1291 additions and 79 deletions
20
backend/WordVersioning.Api/Models/Document.cs
Normal file
20
backend/WordVersioning.Api/Models/Document.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
namespace WordVersioning.Api.Models;
|
||||
|
||||
/// <summary>เอกสารหนึ่งฉบับที่ถูก track — 1 document : N versions (spec ส่วน 7)</summary>
|
||||
public class Document
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>ค่า custom property `SavedByAddIn` ที่ stamp ไว้ในไฟล์ (FR-1)</summary>
|
||||
public string AddInSignature { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>เอกสารที่สร้างจาก template (FR-10) — null ถ้า track เอกสารเปล่า
|
||||
/// (Phase 3 จะเติม FK ไป Template เมื่อมี entity)</summary>
|
||||
public Guid? TemplateId { get; set; }
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
public List<DocumentVersion> Versions { get; set; } = new();
|
||||
}
|
||||
28
backend/WordVersioning.Api/Models/DocumentVersion.cs
Normal file
28
backend/WordVersioning.Api/Models/DocumentVersion.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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>เริ่มที่ 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>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; }
|
||||
}
|
||||
28
backend/WordVersioning.Api/Models/VersionDtos.cs
Normal file
28
backend/WordVersioning.Api/Models/VersionDtos.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WordVersioning.Api.Models;
|
||||
|
||||
/// <summary>body ของ POST /api/documents/{documentId}/versions (multipart/form-data)</summary>
|
||||
public class UploadVersionRequest
|
||||
{
|
||||
[Required]
|
||||
public IFormFile File { get; set; } = null!;
|
||||
|
||||
/// <summary>GUID ที่ client generate ต่อ version — ใช้เป็นส่วนหนึ่งของ object key</summary>
|
||||
[Required]
|
||||
public string ClientVersionId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>JSON object map tag→text จาก content controls (FR-11 — Phase 3 จะใช้ sync เต็มรูปแบบ)</summary>
|
||||
public string? Fields { get; set; }
|
||||
}
|
||||
|
||||
public record UploadVersionResponse(Guid VersionId, int VersionNumber);
|
||||
|
||||
/// <summary>item ของ version history — fields คือ snapshot ที่ parse แล้ว (ถ้ามี)</summary>
|
||||
public record VersionListItem(
|
||||
Guid VersionId,
|
||||
int VersionNumber,
|
||||
DateTimeOffset CreatedAt,
|
||||
string CreatedByUserId,
|
||||
string ContentHash,
|
||||
object? Fields);
|
||||
Loading…
Add table
Add a link
Reference in a new issue