refactor:完成变量表的重构添加,删除,更新

This commit is contained in:
2025-10-23 16:25:22 +08:00
parent 54d040b45f
commit 125348486a
15 changed files with 329 additions and 419 deletions

View File

@@ -84,7 +84,7 @@ public class VariableViewService : IVariableViewService
}
var variableTable = _mapper.Map<VariableTable>(variableTableItem);
if (await _appCenterService.VariableTableManagementService.UpdateVariableTableAsync(variableTable) > 0)
if (await _appCenterService.VariableTableManagementService.UpdateAsync(variableTable) > 0)
{
// 更新数据库后会自动更新内存,无需额外操作
return true;
@@ -93,35 +93,6 @@ public class VariableViewService : IVariableViewService
return false;
}
/// <summary>
/// 删除变量表。
/// </summary>
public async Task<bool> DeleteVariableTable(VariableTableItem variableTable, bool isDeleteDb = false)
{
if (variableTable == null)
{
return false;
}
if (isDeleteDb)
{
if (!await _appCenterService.VariableTableManagementService.DeleteVariableTableAsync(variableTable.Id))
{
return false;
}
}
// 删除与当前变量表关联的所有变量
foreach (var variable in variableTable.Variables)
{
_viewDataService.Variables.Remove(variable.Id);
}
// 删除变量表
_viewDataService.VariableTables.Remove(variableTable.Id);
variableTable.Device.VariableTables.Remove(variableTable);
return true;
}
/// <summary>
/// 添加变量。