chore: 完成v1.2版本迭代与代码清理
本次提交完成了多项清理与规范工作: 1. 移除默认管理员硬编码配置与云同步相关代码 2. 简化前端与MAUI端的配置,关闭静态资源托管以外的冗余功能 3. 清理.gitignore与协调目录,移除临时文件与冗余规则 4. 统一项目命名规范,修正包名与版本号 5. 重构后端数据模型,移除ABP审计字段与云同步相关逻辑 6. 简化WebView配置与系统栏样式,移除不必要的平台检测代码 7. 更新文档与规则文件,完善项目规范与版本记录
This commit is contained in:
@@ -22,17 +22,13 @@ public class TaskRepository : ITaskRepository
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有任务(本地用户),平面加载以支持任意深度树构建。
|
||||
/// 不再使用 Include(t => t.SubTasks) 因为 EF Core 无法递归加载未知深度的子任务;
|
||||
/// 树的构建交由 <see cref="TaskService.GetAllTasksAsync"/> 通过 parentTaskId 在内存中完成。
|
||||
/// 获取所有任务。
|
||||
/// </summary>
|
||||
/// <returns>包含所有任务实体的平面列表。</returns>
|
||||
/// <returns>包含所有任务实体的列表。</returns>
|
||||
public async Task<List<TaskEntity>> GetAllAsync()
|
||||
{
|
||||
return await _context.Tasks
|
||||
.AsNoTracking()
|
||||
.Where(t => t.UserId == TodoUserIds.LocalUserId)
|
||||
.OrderByDescending(t => t.CreationTime)
|
||||
.Include(t => t.SubTasks)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@@ -41,11 +37,11 @@ public class TaskRepository : ITaskRepository
|
||||
/// </summary>
|
||||
/// <param name="id">任务 ID。</param>
|
||||
/// <returns>匹配的任务实体;如果不存在则返回 null。</returns>
|
||||
public async Task<TaskEntity?> GetByIdAsync(Guid id)
|
||||
public async Task<TaskEntity?> GetByIdAsync(int id)
|
||||
{
|
||||
return await _context.Tasks
|
||||
.Include(t => t.SubTasks)
|
||||
.FirstOrDefaultAsync(t => t.Id == id && t.UserId == TodoUserIds.LocalUserId);
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -55,8 +51,8 @@ public class TaskRepository : ITaskRepository
|
||||
public async Task<List<TaskEntity>> GetActiveTasksAsync()
|
||||
{
|
||||
return await _context.Tasks
|
||||
.Where(t => t.UserId == TodoUserIds.LocalUserId && !t.IsCompleted)
|
||||
.OrderByDescending(t => t.CreationTime)
|
||||
.Where(t => !t.IsCompleted)
|
||||
.OrderByDescending(t => t.CreatedAt)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@@ -67,8 +63,8 @@ public class TaskRepository : ITaskRepository
|
||||
public async Task<List<TaskEntity>> GetCompletedTasksAsync()
|
||||
{
|
||||
return await _context.Tasks
|
||||
.Where(t => t.UserId == TodoUserIds.LocalUserId && t.IsCompleted)
|
||||
.OrderByDescending(t => t.LastModificationTime)
|
||||
.Where(t => t.IsCompleted)
|
||||
.OrderByDescending(t => t.UpdatedAt)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@@ -79,13 +75,6 @@ public class TaskRepository : ITaskRepository
|
||||
/// <returns>已持久化的任务实体(包含生成的 ID)。</returns>
|
||||
public async Task<TaskEntity> AddAsync(TaskEntity taskEntity)
|
||||
{
|
||||
taskEntity.UserId = TodoUserIds.LocalUserId;
|
||||
if (taskEntity.Id == Guid.Empty)
|
||||
{
|
||||
taskEntity.Id = Guid.NewGuid();
|
||||
}
|
||||
taskEntity.CreationTime = DateTime.UtcNow;
|
||||
taskEntity.CreatorId = taskEntity.UserId;
|
||||
_context.Tasks.Add(taskEntity);
|
||||
await _context.SaveChangesAsync();
|
||||
return taskEntity;
|
||||
@@ -98,20 +87,20 @@ public class TaskRepository : ITaskRepository
|
||||
/// <returns>更新后的任务实体。</returns>
|
||||
public async Task<TaskEntity> UpdateAsync(TaskEntity taskEntity)
|
||||
{
|
||||
taskEntity.LastModificationTime = DateTime.UtcNow;
|
||||
taskEntity.LastModifierId = taskEntity.UserId;
|
||||
taskEntity.UpdatedAt = DateTime.UtcNow;
|
||||
_context.Tasks.Update(taskEntity);
|
||||
await _context.SaveChangesAsync();
|
||||
return taskEntity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据 ID 删除任务(物理删除)。
|
||||
/// 根据 ID 删除任务。
|
||||
/// </summary>
|
||||
/// <param name="id">要删除的任务 ID。</param>
|
||||
public async Task DeleteAsync(Guid id)
|
||||
/// <returns>表示删除操作的任务。</returns>
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
var task = await _context.Tasks.FirstOrDefaultAsync(t => t.Id == id && t.UserId == TodoUserIds.LocalUserId);
|
||||
var task = await _context.Tasks.FindAsync(id);
|
||||
if (task != null)
|
||||
{
|
||||
_context.Tasks.Remove(task);
|
||||
@@ -124,11 +113,11 @@ public class TaskRepository : ITaskRepository
|
||||
/// </summary>
|
||||
/// <param name="parentTaskId">父任务 ID。</param>
|
||||
/// <returns>子任务实体的列表。</returns>
|
||||
public async Task<List<TaskEntity>> GetSubTasksAsync(Guid parentTaskId)
|
||||
public async Task<List<TaskEntity>> GetSubTasksAsync(int parentTaskId)
|
||||
{
|
||||
return await _context.Tasks
|
||||
.Where(t => t.UserId == TodoUserIds.LocalUserId && t.ParentTaskId == parentTaskId)
|
||||
.OrderByDescending(t => t.CreationTime)
|
||||
.Where(t => t.ParentTaskId == parentTaskId)
|
||||
.OrderByDescending(t => t.CreatedAt)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user