重构服务类和仓库类
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DMS.Infrastructure.Interfaces
|
||||
{
|
||||
public interface IDbContext
|
||||
{
|
||||
// Define common database operations here, e.g.,
|
||||
// Task<TEntity> GetByIdAsync<TEntity>(int id) where TEntity : class;
|
||||
// Task AddAsync<TEntity>(TEntity entity) where TEntity : class;
|
||||
// Task UpdateAsync<TEntity>(TEntity entity) where TEntity : class;
|
||||
// Task DeleteAsync<TEntity>(TEntity entity) where TEntity : class;
|
||||
// ITransaction GetClient(); // This should NOT be here if you want to hide SqlSugar
|
||||
|
||||
// For now, we'll just keep it empty or add methods as needed.
|
||||
// The primary goal is to abstract away ITransaction.
|
||||
// The ITransaction already handles transactions.
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using DMS.Core.Models;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -11,5 +12,8 @@ namespace DMS.Infrastructure.Interfaces
|
||||
Task<int> DeleteAsync(DbDevice model);
|
||||
Task<List<DbDevice>> GetAllAsync();
|
||||
Task<DbDevice> GetByIdAsync(int id);
|
||||
Task BeginTranAsync();
|
||||
Task CommitTranAsync();
|
||||
Task RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
@@ -2,21 +2,18 @@ using DMS.Core.Models;
|
||||
using DMS.Core.Enums;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using DMS.Infrastructure.Entities;
|
||||
|
||||
namespace DMS.Infrastructure.Interfaces
|
||||
{
|
||||
public interface IMenuRepository
|
||||
{
|
||||
Task<int> DeleteAsync(MenuBean menu);
|
||||
Task<int> DeleteAsync(MenuBean menu, ITransaction db);
|
||||
Task<List<MenuBean>> GetMenuTreesAsync();
|
||||
Task<int> AddAsync(MenuBean menu);
|
||||
Task<int> AddAsync(MenuBean menu, ITransaction db);
|
||||
Task<int> AddVarTableMenuAsync(Device dbDevice, int parentMenuId, ITransaction db);
|
||||
Task<int> AddAsync(Device device, ITransaction db);
|
||||
Task<int> UpdateAsync(MenuBean menu);
|
||||
|
||||
Task<MenuBean?> GetMenuByDataIdAsync(int dataId, MenuType menuType);
|
||||
Task<MenuBean> GetMainMenuByNameAsync(string name);
|
||||
Task<int> DeleteAsync(DbMenu menu);
|
||||
Task<List<DbMenu>> GetMenuTreesAsync();
|
||||
Task<DbMenu> AddAsync(DbMenu menu);
|
||||
Task<int> UpdateAsync(DbMenu menu);
|
||||
Task BeginTranAsync();
|
||||
Task CommitTranAsync();
|
||||
Task RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using DMS.Core.Models;
|
||||
using DMS.Infrastructure.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -6,10 +7,13 @@ namespace DMS.Infrastructure.Interfaces
|
||||
{
|
||||
public interface IMqttRepository
|
||||
{
|
||||
Task<Mqtt> GetByIdAsync(int id);
|
||||
Task<List<Mqtt>> GetAllAsync();
|
||||
Task<int> AddAsync(Mqtt mqtt);
|
||||
Task<int> UpdateAsync(Mqtt mqtt);
|
||||
Task<int> DeleteAsync(Mqtt mqtt);
|
||||
Task<DbMqtt> GetByIdAsync(int id);
|
||||
Task<List<DbMqtt>> GetAllAsync();
|
||||
Task<int> AddAsync(DbMqtt mqtt);
|
||||
Task<int> UpdateAsync(DbMqtt mqtt);
|
||||
Task<int> DeleteAsync(DbMqtt mqtt);
|
||||
Task BeginTranAsync();
|
||||
Task CommitTranAsync();
|
||||
Task RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DMS.Infrastructure.Interfaces
|
||||
{
|
||||
public interface ITransaction
|
||||
{
|
||||
Task BeginTranAsync();
|
||||
Task CommitTranAsync();
|
||||
SqlSugarClient GetInstance();
|
||||
Task RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
@@ -11,5 +11,8 @@ namespace DMS.Infrastructure.Interfaces
|
||||
Task<int> AddAsync(User user);
|
||||
Task<int> UpdateAsync(User user);
|
||||
Task<int> DeleteAsync(int id);
|
||||
Task BeginTranAsync();
|
||||
Task CommitTranAsync();
|
||||
Task RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
@@ -7,23 +7,12 @@ namespace DMS.Infrastructure.Interfaces
|
||||
public interface IVarDataRepository
|
||||
{
|
||||
Task<Variable> GetByIdAsync(int id);
|
||||
Task<Variable> GetByIdAsync(int id, ITransaction db);
|
||||
Task<List<Variable>> GetAllAsync();
|
||||
Task<List<Variable>> GetAllAsync(ITransaction db);
|
||||
Task<List<Variable>> GetByVariableTableIdAsync(int varTableId);
|
||||
Task<List<Variable>> GetByVariableTableIdAsync(int varTableId, ITransaction db);
|
||||
Task<Variable> AddAsync(Variable variable);
|
||||
Task<Variable> AddAsync(Variable variable, ITransaction db);
|
||||
Task<int> AddAsync(IEnumerable<Variable> variableDatas);
|
||||
Task<int> AddAsync(IEnumerable<Variable> variableDatas, ITransaction db);
|
||||
Task<int> UpdateAsync(Variable variable);
|
||||
Task<int> UpdateAsync(Variable variable, ITransaction db);
|
||||
Task<int> UpdateAsync(List<Variable> variableDatas);
|
||||
Task<int> UpdateAsync(List<Variable> variableDatas, ITransaction db);
|
||||
Task<int> DeleteAsync(Variable variable);
|
||||
Task<int> DeleteAsync(Variable variable, ITransaction db);
|
||||
Task<int> DeleteAsync(IEnumerable<Variable> variableDatas);
|
||||
|
||||
Task<int> AddMqttToVariablesAsync(IEnumerable<VariableMqtt> variableMqttList);
|
||||
Task BeginTranAsync();
|
||||
Task CommitTranAsync();
|
||||
Task RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,9 @@ namespace DMS.Infrastructure.Interfaces
|
||||
Task<int> DeleteAsync(DbVariableTable variableTable);
|
||||
Task<List<DbVariableTable>> GetAllAsync();
|
||||
Task<DbVariableTable> GetByIdAsync(int id);
|
||||
Task BeginTranAsync();
|
||||
Task CommitTranAsync();
|
||||
Task RollbackTranAsync();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,12 @@ namespace DMS.Infrastructure.Interfaces
|
||||
{
|
||||
public interface IVariableMqttAliasRepository
|
||||
{
|
||||
Task<VariableMqtt?> GetAliasByVariableAndMqtt(int variableDataId, int mqttId);
|
||||
Task<VariableMqtt?> GetAliasByVariableAndMqtt(int variableDataId, int mqttId, ITransaction db);
|
||||
Task<int> AddManyAsync(IEnumerable<VariableMqtt> entities);
|
||||
Task<int> AddManyAsync(IEnumerable<VariableMqtt> entities, ITransaction db);
|
||||
Task<VariableMqtt?> GetByIdAsync(int variableDataId, int mqttId);
|
||||
Task<int> UpdateAliasAsync(int variableDataId, int mqttId, string newAlias);
|
||||
Task<int> UpdateAliasAsync(int variableDataId, int mqttId, string newAlias, ITransaction db);
|
||||
Task<int> DeleteAsync(int variableDataId, int mqttId);
|
||||
|
||||
Task BeginTranAsync();
|
||||
Task CommitTranAsync();
|
||||
Task RollbackTranAsync();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user