Phase 3
This commit is contained in:
parent
9321f5a370
commit
25c2ce53cd
23 changed files with 1746 additions and 68 deletions
81
backend/WordVersioning.Api/Models/TemplateDtos.cs
Normal file
81
backend/WordVersioning.Api/Models/TemplateDtos.cs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WordVersioning.Api.Models;
|
||||
|
||||
/// <summary>body ของ POST /api/templates (multipart/form-data)</summary>
|
||||
public class CreateTemplateRequest
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Required]
|
||||
public IFormFile File { get; set; } = null!;
|
||||
}
|
||||
|
||||
/// <summary>body ของ PUT /api/templates/{id} — Fields เป็น optional (ไม่ส่ง = แก้ metadata อย่างเดียว)</summary>
|
||||
public class UpdateTemplateRequest
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public bool? IsActive { get; set; }
|
||||
|
||||
public List<TemplateFieldDefinition>? Fields { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>นิยาม field หนึ่งตัวที่ admin ตั้ง — Key ต้องตรงกับที่ detect จากไฟล์ (เพิ่ม/ลบ key ต้องผ่าน replace ไฟล์)</summary>
|
||||
public class TemplateFieldDefinition
|
||||
{
|
||||
[Required]
|
||||
public string Key { get; set; } = string.Empty;
|
||||
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>text | number | date</summary>
|
||||
public string Type { get; set; } = "text";
|
||||
|
||||
public bool IsRequired { get; set; }
|
||||
|
||||
public int SortOrder { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>body ของ PUT /api/templates/{id}/file (multipart/form-data)</summary>
|
||||
public class ReplaceTemplateFileRequest
|
||||
{
|
||||
[Required]
|
||||
public IFormFile File { get; set; } = null!;
|
||||
}
|
||||
|
||||
public record TemplateFieldDto(Guid Id, string Key, string Label, string Type, 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<TemplateFieldDto> Fields);
|
||||
|
||||
/// <summary>response ของ POST /api/templates — fields ที่ detect อัตโนมัติพร้อมค่า default
|
||||
/// ให้ admin ไปตั้ง label/type/required ต่อผ่าน PUT (FR-9)</summary>
|
||||
public record CreateTemplateResponse(Guid Id, IReadOnlyList<TemplateFieldDto> Fields);
|
||||
|
||||
/// <summary>response ของ PUT /api/templates/{id}/file — เตือน tag ที่หายไป/เพิ่มมาหลัง replace ไฟล์</summary>
|
||||
public record ReplaceTemplateFileResponse(
|
||||
Guid Id,
|
||||
IReadOnlyList<TemplateFieldDto> Fields,
|
||||
IReadOnlyList<string> AddedTags,
|
||||
IReadOnlyList<string> RemovedTags);
|
||||
Loading…
Add table
Add a link
Reference in a new issue