using System.Text.Json.Serialization;
using Hua.Todo.Core.Entities;
namespace Hua.Todo.Application.CloudSync.Models;
///
/// 云同步任务条目(ABP 标准)。
///
public class CloudTaskItem
{
///
/// 任务 ID(服务端分配,Guid)。
///
[JsonPropertyName("id")]
public Guid Id { get; set; }
///
/// 标题。
///
[JsonPropertyName("title")]
public string Title { get; set; } = string.Empty;
///
/// 优先级。
///
[JsonPropertyName("priority")]
public TaskPriority Priority { get; set; }
///
/// 是否完成。
///
[JsonPropertyName("isCompleted")]
public bool IsCompleted { get; set; }
///
/// 任务编号(用户级自增字符串)。
///
[JsonPropertyName("code")]
public string Code { get; set; } = string.Empty;
///
/// 父任务 ID(Guid)。
///
[JsonPropertyName("parentTaskId")]
public Guid? ParentTaskId { get; set; }
// === ABP 审计字段 ===
///
/// 创建时间。
///
[JsonPropertyName("creationTime")]
public DateTime CreationTime { get; set; }
///
/// 创建人 ID。
///
[JsonPropertyName("creatorId")]
public Guid? CreatorId { get; set; }
///
/// 最后修改时间(用于 LWW 冲突判断)。
///
[JsonPropertyName("lastModificationTime")]
public DateTime? LastModificationTime { get; set; }
///
/// 最后修改人 ID。
///
[JsonPropertyName("lastModifierId")]
public Guid? LastModifierId { get; set; }
///
/// 软删除标记。
///
[JsonPropertyName("isDeleted")]
public bool IsDeleted { get; set; }
///
/// 删除时间。
///
[JsonPropertyName("deletionTime")]
public DateTime? DeletionTime { get; set; }
///
/// 删除人 ID。
///
[JsonPropertyName("deleterId")]
public Guid? DeleterId { get; set; }
}
///
/// 任务 Upsert DTO(客户端提交)。
///
public class CloudTaskUpsert
{
///
/// 任务 ID;为 null 表示新建。
///
[JsonPropertyName("id")]
public Guid? Id { get; set; }
///
/// 标题。
///
[JsonPropertyName("title")]
public string Title { get; set; } = string.Empty;
///
/// 优先级。
///
[JsonPropertyName("priority")]
public TaskPriority Priority { get; set; } = TaskPriority.Medium;
///
/// 是否完成。
///
[JsonPropertyName("isCompleted")]
public bool IsCompleted { get; set; }
///
/// 任务编号。
///
[JsonPropertyName("code")]
public string Code { get; set; } = string.Empty;
///
/// 父任务 ID(可选)。
///
[JsonPropertyName("parentTaskId")]
public Guid? ParentTaskId { get; set; }
///
/// 客户端发起变更时写入的时间戳(UTC),用于 LWW 冲突判断。
///
[JsonPropertyName("lastModificationTime")]
public DateTime? LastModificationTime { get; set; }
}
///
/// 同步请求(增改删)。
///
public class SyncRequest
{
///
/// 新增或更新的任务列表。
///
[JsonPropertyName("upserts")]
public List Upserts { get; set; } = new();
///
/// 需要逻辑删除的任务 ID 列表。
///
[JsonPropertyName("deletes")]
public List Deletes { get; set; } = new();
}
///
/// 同步响应。
///
public class SyncResponse
{
///
/// 服务端时间(UTC)。
///
[JsonPropertyName("serverTimeUtc")]
public DateTime ServerTimeUtc { get; set; }
///
/// 当前用户的任务全量(含 Tombstone)。
///
[JsonPropertyName("tasks")]
public List Tasks { get; set; } = new();
}