给DialogService从原来的接口注入,更改为RequestMessage消息通知
This commit is contained in:
@@ -4,21 +4,17 @@ namespace PMSWPF.Data;
|
||||
|
||||
public class DbContext
|
||||
{
|
||||
private static SqlSugarClient _db;
|
||||
|
||||
public static SqlSugarClient GetInstance()
|
||||
{
|
||||
if (_db == null)
|
||||
var connectionString = "server=127.0.0.1;port=3306;user=root;password=Pgw15221236646; database=pmswpf;";
|
||||
var _db = new SqlSugarClient(new ConnectionConfig
|
||||
{
|
||||
var connectionString = "server=127.0.0.1;port=3306;user=root;password=Pgw15221236646; database=pmswpf;";
|
||||
_db = new SqlSugarClient(new ConnectionConfig
|
||||
{
|
||||
ConnectionString = connectionString,
|
||||
DbType = DbType.MySql, // 根据实际数据库类型修改,如DbType.MySql等
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = InitKeyType.Attribute
|
||||
});
|
||||
}
|
||||
ConnectionString = connectionString,
|
||||
DbType = DbType.MySql, // 根据实际数据库类型修改,如DbType.MySql等
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = InitKeyType.Attribute
|
||||
});
|
||||
|
||||
|
||||
return _db;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Windows.Controls;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Extensions;
|
||||
using PMSWPF.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace PMSWPF.Data.Repositories;
|
||||
@@ -13,13 +15,21 @@ public class MenuRepositories
|
||||
_db=DbContext.GetInstance();
|
||||
}
|
||||
|
||||
public async Task<List<DbMenu>> GetMenu()
|
||||
public async Task<List<MenuBean>> GetMenu()
|
||||
{
|
||||
return await _db.Queryable<DbMenu>().ToListAsync();
|
||||
// //无主键用法新:5.1.4.110
|
||||
// db.Queryable<Tree>().ToTree(it=>it.Child,it=>it.ParentId,0,it=>it.Id)//+4重载
|
||||
List<MenuBean> menus=new();
|
||||
var dbMenuList=await _db.Queryable<DbMenu>().ToTreeAsync(dm=>dm.Items,dm=>dm.ParentId,0);
|
||||
foreach (var item in dbMenuList)
|
||||
{
|
||||
menus.Add(item.CopyTo<MenuBean>());
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
|
||||
public async Task<int> AddMenu(DbMenu dbMenu)
|
||||
public async Task<int> AddMenu(MenuBean menu)
|
||||
{
|
||||
return await _db.Insertable<DbMenu>(dbMenu).ExecuteCommandAsync();
|
||||
return await _db.Insertable<DbMenu>(menu.CopyTo<DbMenu>()).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user