using System.ComponentModel.DataAnnotations; namespace WordVersioning.Api.Models; /// body ของ POST /api/templates (multipart/form-data) public class CreateTemplateRequest { [Required] public string Name { get; set; } = string.Empty; public string? Description { get; set; } [Required] public IFormFile File { get; set; } = null!; } /// body ของ PUT /api/templates/{id} — Fields เป็น optional (ไม่ส่ง = แก้ metadata อย่างเดียว) public class UpdateTemplateRequest { public string? Name { get; set; } public string? Description { get; set; } public bool? IsActive { get; set; } public List? Fields { get; set; } } /// นิยาม field หนึ่งตัวที่ admin ตั้ง — Key ต้องตรงกับที่ detect จากไฟล์ (เพิ่ม/ลบ key ต้องผ่าน replace ไฟล์) public class TemplateFieldDefinition { [Required] public string Key { get; set; } = string.Empty; public string Label { get; set; } = string.Empty; /// text | number | date public string Type { get; set; } = "text"; /// editor ต่อ field (FR-14) — textbox|textarea ตาม type · ไม่ส่ง/ว่าง = default ของ type public string? Editor { get; set; } public bool IsRequired { get; set; } public int SortOrder { get; set; } } /// body ของ PUT /api/templates/{id}/file (multipart/form-data) public class ReplaceTemplateFileRequest { [Required] public IFormFile File { get; set; } = null!; } public record TemplateFieldDto(Guid Id, string Key, string Label, string Type, string Editor, bool IsRequired, int SortOrder); public record TemplateListItem( Guid Id, string Name, string? Description, bool IsActive, int FieldCount, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt); public record TemplateDetail( Guid Id, string Name, string? Description, bool IsActive, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt, IReadOnlyList Fields); /// response ของ POST /api/templates — fields ที่ detect อัตโนมัติพร้อมค่า default /// ให้ admin ไปตั้ง label/type/required ต่อผ่าน PUT (FR-9) public record CreateTemplateResponse(Guid Id, IReadOnlyList Fields); /// response ของ PUT /api/templates/{id}/file — เตือน tag ที่หายไป/เพิ่มมาหลัง replace ไฟล์ public record ReplaceTemplateFileResponse( Guid Id, IReadOnlyList Fields, IReadOnlyList AddedTags, IReadOnlyList RemovedTags);