diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsClassifyService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsClassifyService.cs
index 0e565ae..3f21ed6 100644
--- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsClassifyService.cs
+++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsClassifyService.cs
@@ -124,7 +124,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
///
public async Task> GetRelation(string classifyId)
{
- var result = await _db.Queryable().Where(t => t.ClassifyId == classifyId)
+ var result = await _db.Queryable().LeftJoin((a, b) => a.GoodsId == b.Id)
+ .Where((a, b) => a.ClassifyId == classifyId)
+ .OrderByDescending((a, b) => b.CreateAt)
.Select(a => new RelationGoodsIdDto
{
GoodsId = a.GoodsId,
diff --git a/BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleMenuDtoInput.cs b/BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleMenuDtoInput.cs
index c0f825d..2368268 100644
--- a/BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleMenuDtoInput.cs
+++ b/BPA.SAAS.Manage.Application/Org/Dtos/Role/RoleMenuDtoInput.cs
@@ -18,4 +18,17 @@ namespace BPA.SAAS.Manage.Application.Org.Dtos.Role
///
public List SysMenuId { get; set; }
}
+
+ public class RoleBasicMenuDtoInput
+ {
+ ///
+ /// 角色Id
+ ///
+ public string SysRoleId { get; set; }
+
+ ///
+ /// 功能菜单Id
+ ///
+ public List SysBasicMenuId { get; set; }
+ }
}
diff --git a/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs b/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs
index 8f3a997..df9846e 100644
--- a/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs
+++ b/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs
@@ -19,5 +19,8 @@ namespace BPA.SAAS.Manage.Application.Org.Interface
Task Disable(string Id);
Task Enable(string Id);
Task> GetRole();
+ Task> GetBasicMenuRole(string roleId);
+ Task UpdateBasicMenuRole(RoleBasicMenuDtoInput input);
+ Task> GetRoleBasicMenu();
}
}
diff --git a/BPA.SAAS.Manage.Application/Org/RolesServices.cs b/BPA.SAAS.Manage.Application/Org/RolesServices.cs
index c558fd7..8054c33 100644
--- a/BPA.SAAS.Manage.Application/Org/RolesServices.cs
+++ b/BPA.SAAS.Manage.Application/Org/RolesServices.cs
@@ -106,5 +106,33 @@ namespace BPA.SAAS.Manage.Application.Org
{
return await _roleService.GetRole();
}
+ ///
+ /// 根据角色查询角色基础功能菜单
+ ///
+ ///
+ [HttpGet("/api/roles/getBasicMenuRole")]
+ public async Task> GetBasicMenuRole(string roleId)
+ {
+ return await _roleService.GetBasicMenuRole(roleId);
+ }
+ ///
+ /// 更新角色基础功能菜单
+ ///
+ ///
+ ///
+ [HttpPost("/api/roles/updateBasicMenuRole")]
+ public async Task UpdateBasicMenuRole(RoleBasicMenuDtoInput input)
+ {
+ return await _roleService.UpdateBasicMenuRole(input);
+ }
+ ///
+ /// 获取用户基础功能权限编码列表
+ ///
+ ///
+ [HttpGet("/api/roles/getRoleBasicMenu")]
+ public async Task> GetRoleBasicMenu()
+ {
+ return await _roleService.GetRoleBasicMenu();
+ }
}
}
diff --git a/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs b/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs
index a96e653..df3a4e7 100644
--- a/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs
+++ b/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs
@@ -232,5 +232,73 @@ namespace BPA.SAAS.Manage.Application.Org.Services
var str = string.Format("{0}", ram.ToString().Substring(0, Length));
return str;
}
+
+ public async Task> GetBasicMenuRole(string roleId)
+ {
+ return await _db.Queryable().LeftJoin((t, x) => t.SysBasicMenuId == x.Id)
+ .Where(t => t.SysRoleId == roleId).OrderBy((t, x) => x.CreateAt).Select((t, x) => new QueryRoleMenuListDto()
+ {
+ Id = x.Id,
+ Name = x.Name,
+ IsParentMenu = string.IsNullOrWhiteSpace(x.Pid)
+ }).ToListAsync();
+ }
+
+ public async Task UpdateBasicMenuRole(RoleBasicMenuDtoInput input)
+ {
+ var models = new List();
+ var newMenuIds = new List();
+ _db.Deleteable(t => t.SysRoleId == input.SysRoleId).ExecuteCommandHasChange();
+ if (input.SysBasicMenuId != null)
+ {
+ var basicMenus = await _db.Queryable().ToListAsync();
+ foreach (var item in input.SysBasicMenuId)
+ {
+ var pid = basicMenus.FirstOrDefault(t => t.Id == item).Pid;
+ if (pid != null && pid != "")
+ {
+ var pid2 = basicMenus.FirstOrDefault(t => t.Id == pid).Pid;
+ if (pid2 != null)
+ {
+ newMenuIds.Add(pid2);
+ }
+ newMenuIds.Add(pid);
+ }
+ newMenuIds.Add(item);
+ }
+ newMenuIds.Distinct().ToList().ForEach(item =>
+ {
+ models.Add(new BPA_RoleBasicMenu
+ {
+ Id = Guid.NewGuid().ToString(),
+ SysBasicMenuId = item,
+ SysRoleId = input.SysRoleId
+ });
+ });
+ }
+ if (models.Count <= 0)
+ return true;
+ return await _db.Insertable(models).ExecuteCommandAsync() > 0;
+ }
+
+ ///
+ /// 获取用户基础功能权限编码列表
+ ///
+ ///
+ public async Task> GetRoleBasicMenu()
+ {
+ var result = new List();
+ var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
+ var sysRoleIdList = await _db.Queryable().Where(t => t.SysUserId == userId).Select(a => a.SysRoleId).ToListAsync();
+ var roleBasicMenuIdList = await _db.Queryable().Where(t => sysRoleIdList.Contains(t.SysRoleId)).Select(a => a.SysBasicMenuId).Distinct().ToListAsync();
+ var basicMenuList = await _db.Queryable().ToListAsync();
+ foreach (var id in roleBasicMenuIdList)
+ {
+ var menuCode = basicMenuList.FirstOrDefault(t => t.Id == id)?.Code;
+ if (menuCode != null)
+ result.Add(menuCode);
+ }
+ return result;
+ }
}
}
diff --git a/BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs b/BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs
index c485aa5..b9112f1 100644
--- a/BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs
+++ b/BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs
@@ -19,5 +19,6 @@ namespace BPA.SAAS.Manage.Application.System.Interface
Task> DymicMenuTree(int type);
Task Enable(string Id);
Task Disable(string Id);
+ Task> BasicMenuTree();
}
}
diff --git a/BPA.SAAS.Manage.Application/System/MenuServices.cs b/BPA.SAAS.Manage.Application/System/MenuServices.cs
index 6c7cf52..81b082e 100644
--- a/BPA.SAAS.Manage.Application/System/MenuServices.cs
+++ b/BPA.SAAS.Manage.Application/System/MenuServices.cs
@@ -87,5 +87,14 @@ namespace BPA.SAAS.Manage.Application.System
{
return await _menuService.Disable(Id);
}
+ ///
+ /// 获取基础功能树
+ ///
+ ///
+ [HttpGet("/api/menu/basicMenuTree")]
+ public async Task> BasicMenuTree()
+ {
+ return await _menuService.BasicMenuTree();
+ }
}
}
diff --git a/BPA.SAAS.Manage.Application/System/Services/MenuService.cs b/BPA.SAAS.Manage.Application/System/Services/MenuService.cs
index 084e647..92d9b90 100644
--- a/BPA.SAAS.Manage.Application/System/Services/MenuService.cs
+++ b/BPA.SAAS.Manage.Application/System/Services/MenuService.cs
@@ -330,6 +330,24 @@ namespace BPA.SAAS.Manage.Application.System.Services
}
}
+
+ public async Task> BasicMenuTree()
+ {
+ var allMenus = await _db.Queryable().OrderBy(t => t.Sort).ToListAsync();
+ List buildMenuTree(string parentId)
+ {
+ return allMenus.Where(t => t.Pid == parentId)
+ .Select(t => new MenuTreeOutput
+ {
+ Key = t.Id,
+ Title = t.Name,
+ value = t.Id,
+ Children = buildMenuTree(t.Id)
+ }).ToList();
+ }
+ return buildMenuTree(null);
+ }
+
public async Task> MenuTree()
{
var AllMenus = _db.Queryable().OrderBy(t => t.Sort).ToList();
diff --git a/BPA.SAAS.Manage.Core/System/BPA_BasicMenu.cs b/BPA.SAAS.Manage.Core/System/BPA_BasicMenu.cs
new file mode 100644
index 0000000..491150e
--- /dev/null
+++ b/BPA.SAAS.Manage.Core/System/BPA_BasicMenu.cs
@@ -0,0 +1,35 @@
+using BPA.SAAS.Manage.Core.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.Manage.Core.System
+{
+ ///
+ /// 基础功能菜单表
+ ///
+ public class BPA_BasicMenu
+ {
+ public string Id { get; set; }
+ ///
+ /// 父级Id
+ ///
+ public string Pid { get; set; }
+ ///
+ /// 菜单名称
+ ///
+ public string Name { get; set; }
+ ///
+ /// 菜单编码 唯一
+ ///
+ public string Code { get; set; }
+ ///
+ /// 排序
+ ///
+ public int Sort { get; set; }
+ public DateTime CreateAt { get; set; }
+ public string CreateBy { get; set; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Core/System/BPA_RoleBasicMenu.cs b/BPA.SAAS.Manage.Core/System/BPA_RoleBasicMenu.cs
new file mode 100644
index 0000000..be0c110
--- /dev/null
+++ b/BPA.SAAS.Manage.Core/System/BPA_RoleBasicMenu.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.Manage.Core.System
+{
+ ///
+ /// 角色基础功能关系表
+ ///
+ public class BPA_RoleBasicMenu
+ {
+ public string Id { get; set; }
+ public string SysRoleId { get; set; }
+ public string SysBasicMenuId { get; set; }
+ }
+}