按照软件设计文档开始重构代码01
This commit is contained in:
@@ -22,28 +22,28 @@ public class MenuRepository : BaseRepository<DbMenu>,IMenuRepository
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var dbMenuTree = await Db.Queryable<DbMenu>()
|
||||
.ToTreeAsync(dm => dm.Items, dm => dm.ParentId, 0);
|
||||
.ToTreeAsync(dm => dm.Childrens, dm => dm.ParentId, 0);
|
||||
stopwatch.Stop();
|
||||
NlogHelper.Info($"获取菜单树耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return dbMenuTree;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 编辑菜单,支持事务
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public async Task<DbMenu?> GetMenuByDataIdAsync(int dataId, MenuType menuType)
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var result = await Db.Queryable<DbMenu>()
|
||||
.FirstAsync(m => m.DataId == dataId && m.Type == menuType);
|
||||
stopwatch.Stop();
|
||||
NlogHelper.Info($"根据DataId '{dataId}' 和 MenuType '{menuType}' 获取菜单耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
// /// <summary>
|
||||
// /// 编辑菜单,支持事务
|
||||
// /// </summary>
|
||||
// /// <param name="menu"></param>
|
||||
// /// <returns></returns>
|
||||
//
|
||||
// public async Task<DbMenu?> GetMenuByDataIdAsync(int dataId, MenuType menuType)
|
||||
// {
|
||||
// Stopwatch stopwatch = new Stopwatch();
|
||||
// stopwatch.Start();
|
||||
// var result = await Db.Queryable<DbMenu>()
|
||||
// .FirstAsync(m => m.DataId == dataId && m.Type == menuType);
|
||||
// stopwatch.Stop();
|
||||
// NlogHelper.Info($"根据DataId '{dataId}' 和 MenuType '{menuType}' 获取菜单耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
// return result;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace DMS.Infrastructure.Repositories;
|
||||
/// <summary>
|
||||
/// Mqtt仓储类,用于操作DbMqtt实体
|
||||
/// </summary>
|
||||
public class MqttRepository : BaseRepository<DbMqtt>
|
||||
public class MqttRepository : BaseRepository<DbMqttServer>
|
||||
{
|
||||
|
||||
public MqttRepository(SqlSugarDbContext dbContext)
|
||||
@@ -25,11 +25,11 @@ public class MqttRepository : BaseRepository<DbMqtt>
|
||||
/// </summary>
|
||||
/// <param name="id">主键ID</param>
|
||||
/// <returns></returns>
|
||||
public override async Task<DbMqtt> GetByIdAsync(int id)
|
||||
public override async Task<DbMqttServer> GetByIdAsync(int id)
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var result = await Db.Queryable<DbMqtt>()
|
||||
var result = await Db.Queryable<DbMqttServer>()
|
||||
.In(id)
|
||||
.SingleAsync();
|
||||
stopwatch.Stop();
|
||||
@@ -41,13 +41,11 @@ public class MqttRepository : BaseRepository<DbMqtt>
|
||||
/// 获取所有Mqtt配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override async Task<List<DbMqtt>> GetAllAsync()
|
||||
public override async Task<List<DbMqttServer>> GetAllAsync()
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var result = await Db.Queryable<DbMqtt>()
|
||||
.Includes(m => m.VariableMqtts, vm => vm.Variable)
|
||||
.Includes(m => m.VariableMqtts, vm => vm.Mqtt)
|
||||
var result = await Db.Queryable<DbMqttServer>()
|
||||
.ToListAsync();
|
||||
stopwatch.Stop();
|
||||
NlogHelper.Info($"获取所有Mqtt配置耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
|
||||
@@ -24,8 +24,6 @@ public class VarDataRepository : BaseRepository<DbVariable>
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var result = await Db.Queryable<DbVariable>()
|
||||
.Includes(d => d.VariableTable)
|
||||
.Includes(d => d.VariableTable.Device)
|
||||
.ToListAsync();
|
||||
stopwatch.Stop();
|
||||
//NlogHelper.Info($"获取所有VariableData耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace DMS.Infrastructure.Repositories;
|
||||
/// <summary>
|
||||
/// 变量与MQTT服务器别名关联的数据仓库。
|
||||
/// </summary>
|
||||
public class VariableMqttAliasRepository : BaseRepository<DbVariableMqtt>
|
||||
public class VariableMqttAliasRepository : BaseRepository<DbVariableMqttAlias>
|
||||
{
|
||||
public VariableMqttAliasRepository(SqlSugarDbContext dbContext)
|
||||
: base(dbContext)
|
||||
|
||||
Reference in New Issue
Block a user