@@ -124,7 +124,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<List<RelationGoodsIdDto>> GetRelation(string classifyId) | public async Task<List<RelationGoodsIdDto>> GetRelation(string classifyId) | ||||
{ | { | ||||
var result = await _db.Queryable<BPA_GoodsClassifyRelation>().Where(t => t.ClassifyId == classifyId) | |||||
var result = await _db.Queryable<BPA_GoodsClassifyRelation>().LeftJoin<BPA_GoodsInfo>((a, b) => a.GoodsId == b.Id) | |||||
.Where((a, b) => a.ClassifyId == classifyId) | |||||
.OrderByDescending((a, b) => b.CreateAt) | |||||
.Select(a => new RelationGoodsIdDto | .Select(a => new RelationGoodsIdDto | ||||
{ | { | ||||
GoodsId = a.GoodsId, | GoodsId = a.GoodsId, | ||||
@@ -18,4 +18,17 @@ namespace BPA.SAAS.Manage.Application.Org.Dtos.Role | |||||
/// </summary> | /// </summary> | ||||
public List<string> SysMenuId { get; set; } | public List<string> SysMenuId { get; set; } | ||||
} | } | ||||
public class RoleBasicMenuDtoInput | |||||
{ | |||||
/// <summary> | |||||
/// 角色Id | |||||
/// </summary> | |||||
public string SysRoleId { get; set; } | |||||
/// <summary> | |||||
/// 功能菜单Id | |||||
/// </summary> | |||||
public List<string> SysBasicMenuId { get; set; } | |||||
} | |||||
} | } |
@@ -19,5 +19,8 @@ namespace BPA.SAAS.Manage.Application.Org.Interface | |||||
Task<bool> Disable(string Id); | Task<bool> Disable(string Id); | ||||
Task<bool> Enable(string Id); | Task<bool> Enable(string Id); | ||||
Task<Dictionary<string, object>> GetRole(); | Task<Dictionary<string, object>> GetRole(); | ||||
Task<List<QueryRoleMenuListDto>> GetBasicMenuRole(string roleId); | |||||
Task<bool> UpdateBasicMenuRole(RoleBasicMenuDtoInput input); | |||||
Task<List<string>> GetRoleBasicMenu(); | |||||
} | } | ||||
} | } |
@@ -106,5 +106,33 @@ namespace BPA.SAAS.Manage.Application.Org | |||||
{ | { | ||||
return await _roleService.GetRole(); | return await _roleService.GetRole(); | ||||
} | } | ||||
/// <summary> | |||||
/// 根据角色查询角色基础功能菜单 | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
[HttpGet("/api/roles/getBasicMenuRole")] | |||||
public async Task<List<QueryRoleMenuListDto>> GetBasicMenuRole(string roleId) | |||||
{ | |||||
return await _roleService.GetBasicMenuRole(roleId); | |||||
} | |||||
/// <summary> | |||||
/// 更新角色基础功能菜单 | |||||
/// </summary> | |||||
/// <param name="input"></param> | |||||
/// <returns></returns> | |||||
[HttpPost("/api/roles/updateBasicMenuRole")] | |||||
public async Task<bool> UpdateBasicMenuRole(RoleBasicMenuDtoInput input) | |||||
{ | |||||
return await _roleService.UpdateBasicMenuRole(input); | |||||
} | |||||
/// <summary> | |||||
/// 获取用户基础功能权限编码列表 | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
[HttpGet("/api/roles/getRoleBasicMenu")] | |||||
public async Task<List<string>> GetRoleBasicMenu() | |||||
{ | |||||
return await _roleService.GetRoleBasicMenu(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -232,5 +232,73 @@ namespace BPA.SAAS.Manage.Application.Org.Services | |||||
var str = string.Format("{0}", ram.ToString().Substring(0, Length)); | var str = string.Format("{0}", ram.ToString().Substring(0, Length)); | ||||
return str; | return str; | ||||
} | } | ||||
public async Task<List<QueryRoleMenuListDto>> GetBasicMenuRole(string roleId) | |||||
{ | |||||
return await _db.Queryable<BPA_RoleBasicMenu>().LeftJoin<BPA_BasicMenu>((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<bool> UpdateBasicMenuRole(RoleBasicMenuDtoInput input) | |||||
{ | |||||
var models = new List<BPA_RoleBasicMenu>(); | |||||
var newMenuIds = new List<string>(); | |||||
_db.Deleteable<BPA_RoleBasicMenu>(t => t.SysRoleId == input.SysRoleId).ExecuteCommandHasChange(); | |||||
if (input.SysBasicMenuId != null) | |||||
{ | |||||
var basicMenus = await _db.Queryable<BPA_BasicMenu>().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; | |||||
} | |||||
/// <summary> | |||||
/// 获取用户基础功能权限编码列表 | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
public async Task<List<string>> GetRoleBasicMenu() | |||||
{ | |||||
var result = new List<string>(); | |||||
var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||||
var sysRoleIdList = await _db.Queryable<BPA_UserRole>().Where(t => t.SysUserId == userId).Select(a => a.SysRoleId).ToListAsync(); | |||||
var roleBasicMenuIdList = await _db.Queryable<BPA_RoleBasicMenu>().Where(t => sysRoleIdList.Contains(t.SysRoleId)).Select(a => a.SysBasicMenuId).Distinct().ToListAsync(); | |||||
var basicMenuList = await _db.Queryable<BPA_BasicMenu>().ToListAsync(); | |||||
foreach (var id in roleBasicMenuIdList) | |||||
{ | |||||
var menuCode = basicMenuList.FirstOrDefault(t => t.Id == id)?.Code; | |||||
if (menuCode != null) | |||||
result.Add(menuCode); | |||||
} | |||||
return result; | |||||
} | |||||
} | } | ||||
} | } |
@@ -19,5 +19,6 @@ namespace BPA.SAAS.Manage.Application.System.Interface | |||||
Task<List<MenuRouteDtoOutput>> DymicMenuTree(int type); | Task<List<MenuRouteDtoOutput>> DymicMenuTree(int type); | ||||
Task<bool> Enable(string Id); | Task<bool> Enable(string Id); | ||||
Task<bool> Disable(string Id); | Task<bool> Disable(string Id); | ||||
Task<List<MenuTreeOutput>> BasicMenuTree(); | |||||
} | } | ||||
} | } |
@@ -87,5 +87,14 @@ namespace BPA.SAAS.Manage.Application.System | |||||
{ | { | ||||
return await _menuService.Disable(Id); | return await _menuService.Disable(Id); | ||||
} | } | ||||
/// <summary> | |||||
/// 获取基础功能树 | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
[HttpGet("/api/menu/basicMenuTree")] | |||||
public async Task<List<MenuTreeOutput>> BasicMenuTree() | |||||
{ | |||||
return await _menuService.BasicMenuTree(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -330,6 +330,24 @@ namespace BPA.SAAS.Manage.Application.System.Services | |||||
} | } | ||||
} | } | ||||
public async Task<List<MenuTreeOutput>> BasicMenuTree() | |||||
{ | |||||
var allMenus = await _db.Queryable<BPA_BasicMenu>().OrderBy(t => t.Sort).ToListAsync(); | |||||
List<MenuTreeOutput> 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<List<MenuTreeOutput>> MenuTree() | public async Task<List<MenuTreeOutput>> MenuTree() | ||||
{ | { | ||||
var AllMenus = _db.Queryable<BPA_Menu>().OrderBy(t => t.Sort).ToList(); | var AllMenus = _db.Queryable<BPA_Menu>().OrderBy(t => t.Sort).ToList(); | ||||
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 基础功能菜单表 | |||||
/// </summary> | |||||
public class BPA_BasicMenu | |||||
{ | |||||
public string Id { get; set; } | |||||
/// <summary> | |||||
/// 父级Id | |||||
/// </summary> | |||||
public string Pid { get; set; } | |||||
/// <summary> | |||||
/// 菜单名称 | |||||
/// </summary> | |||||
public string Name { get; set; } | |||||
/// <summary> | |||||
/// 菜单编码 唯一 | |||||
/// </summary> | |||||
public string Code { get; set; } | |||||
/// <summary> | |||||
/// 排序 | |||||
/// </summary> | |||||
public int Sort { get; set; } | |||||
public DateTime CreateAt { get; set; } | |||||
public string CreateBy { get; set; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 角色基础功能关系表 | |||||
/// </summary> | |||||
public class BPA_RoleBasicMenu | |||||
{ | |||||
public string Id { get; set; } | |||||
public string SysRoleId { get; set; } | |||||
public string SysBasicMenuId { get; set; } | |||||
} | |||||
} |