临时提交2

This commit is contained in:
2025-07-21 18:49:49 +08:00
parent 29a2d44319
commit 525c681b6c
57 changed files with 628 additions and 558 deletions

View File

@@ -15,17 +15,17 @@ namespace DMS.Infrastructure.Services
where TRepository : BaseRepository<TEntity>
{
protected readonly IMapper _mapper;
protected readonly TRepository _repository;
protected readonly TRepository ServerRepository;
/// <summary>
/// 初始化 BaseService 的新实例。
/// </summary>
/// <param name="mapper">AutoMapper 实例,用于对象映射。</param>
/// <param name="repository">仓储实例,用于数据访问。</param>
protected BaseService(IMapper mapper, TRepository repository)
/// <param name="serverRepository">仓储实例,用于数据访问。</param>
protected BaseService(IMapper mapper, TRepository serverRepository)
{
_mapper = mapper;
_repository = repository;
ServerRepository = serverRepository;
}
/// <summary>
@@ -36,7 +36,7 @@ namespace DMS.Infrastructure.Services
public virtual async Task<TEntity> AddAsync(TModel model)
{
var entity = _mapper.Map<TEntity>(model);
return await _repository.AddAsync(entity);
return await ServerRepository.AddAsync(entity);
}
/// <summary>
@@ -47,7 +47,7 @@ namespace DMS.Infrastructure.Services
public virtual async Task<int> UpdateAsync(TModel model)
{
var entity = _mapper.Map<TEntity>(model);
return await _repository.UpdateAsync(entity);
return await ServerRepository.UpdateAsync(entity);
}
/// <summary>
@@ -58,7 +58,7 @@ namespace DMS.Infrastructure.Services
public virtual async Task<int> DeleteAsync(TModel model)
{
var entity = _mapper.Map<TEntity>(model);
return await _repository.DeleteAsync(entity);
return await ServerRepository.DeleteAsync(entity);
}
}
}

View File

@@ -7,10 +7,11 @@ using SqlSugar;
using System;
using System.Linq;
using System.Threading.Tasks;
using DMS.Core.Interfaces;
namespace DMS.Infrastructure.Services
{
public class DatabaseInitializerService : DMS.Infrastructure.Interfaces.IDatabaseService
public class DatabaseInitializerService : IDatabaseService
{
private readonly SqlSugarClient _db;

View File

@@ -4,7 +4,6 @@ using DMS.Core.Models;
using DMS.Infrastructure.Data;
using DMS.Infrastructure.Entities;
using DMS.Infrastructure.Repositories;
using DMS.Infrastructure.Interfaces;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -12,6 +11,8 @@ using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using DMS.Core.Interfaces;
using DMS.Core.Interfaces.Repositories;
namespace DMS.Infrastructure.Services
{
@@ -19,7 +20,7 @@ namespace DMS.Infrastructure.Services
{
private readonly IDeviceRepository _deviceRepository;
private readonly IMenuRepository _menuRepository;
private readonly IVarTableRepository _varTableRepository;
private readonly IVariableTableRepository _variableTableRepository;
private readonly IMapper _mapper;
@@ -60,7 +61,7 @@ namespace DMS.Infrastructure.Services
// dbVariableTable.Description = "默认变量表";
// dbVariableTable.DeviceId = addDevice.Id;
// dbVariableTable.ProtocolType = addDevice.ProtocolType;
// var dbAddVarTable= await _varTableRepository.AddAsync(dbVariableTable);
// var dbAddVarTable= await _variableTableRepository.AddAsync(dbVariableTable);
// if (addDevice.VariableTables==null)
// {
// addDevice.VariableTables= new List<DbVariableTable>();

View File

@@ -4,7 +4,6 @@ using DMS.Core.Helper;
using DMS.Core.Models;
using DMS.Infrastructure.Data;
using DMS.Infrastructure.Entities;
using DMS.Infrastructure.Interfaces;
using DMS.Infrastructure.Repositories;
using SqlSugar;
using System;
@@ -14,9 +13,9 @@ using System.Threading.Tasks;
namespace DMS.Infrastructure.Services
{
public class MqttService:BaseService<MqttServer, DbMqttServer, MqttRepository>
public class MqttService:BaseService<MqttServer, DbMqttServer, MqttServerRepository>
{
public MqttService(IMapper mapper, MqttRepository repository) : base(mapper, repository)
public MqttService(IMapper mapper, MqttServerRepository serverRepository) : base(mapper, serverRepository)
{
}
}

View File

@@ -13,11 +13,11 @@ using DMS.Infrastructure.Repositories;
namespace DMS.Infrastructure.Services
{
public class VarDataService : BaseService<Variable, DbVariable, VarDataRepository>
public class VarDataService : BaseService<Variable, DbVariable, VariableRepository>
{
private readonly IMapper _mapper;
public VarDataService(IMapper mapper, VarDataRepository repository) : base(mapper, repository)
public VarDataService(IMapper mapper, VariableRepository repository) : base(mapper, repository)
{
_mapper = mapper;
}

View File

@@ -5,9 +5,9 @@ using DMS.Infrastructure.Repositories;
namespace DMS.Infrastructure.Services;
public class VarTableService : BaseService<VariableTable, DbVariableTable, VarTableRepository>
public class VarTableService : BaseService<VariableTable, DbVariableTable, VariableTableRepository>
{
public VarTableService(IMapper mapper, VarTableRepository repository) : base(mapper, repository)
public VarTableService(IMapper mapper, VariableTableRepository repository) : base(mapper, repository)
{
}
}