using AutoMapper;
using DMS.Application.Interfaces;
using DMS.Application.Interfaces.Management;
using DMS.Application.Services.Management;
using DMS.Core.Models;
using DMS.WPF.Interfaces;
using DMS.WPF.ItemViewModel;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
namespace DMS.WPF.Services;
///
/// 菜单数据服务类,负责管理菜单相关的数据和操作。
///
public class MenuViewService : IMenuViewService
{
private readonly IMapper _mapper;
private readonly IViewDataService _wpfDataService;
private readonly IAppDataService _appDataService;
private readonly IMenuManagementService _menuManagementService;
///
/// MenuDataService类的构造函数。
///
/// AutoMapper 实例。
/// 数据服务中心实例。
public MenuViewService(IMapper mapper, IViewDataService dataStorageService, IAppDataService appStorageService, IMenuManagementService menuManagementService)
{
_mapper = mapper;
_wpfDataService = dataStorageService;
_appDataService = appStorageService;
_menuManagementService = menuManagementService;
}
public void LoadAllMenus()
{
_wpfDataService.Menus = _mapper.Map>(_appDataService.Menus.Values);
BuildMenuTrees();
}
///
/// 构建菜单树。
///
public void BuildMenuTrees()
{
// 创建一个新的临时列表来存储根菜单
var newRootMenus = new List