|
|
@@ -6,6 +6,7 @@ using BPA.SAAS.Manage.Core.Org; |
|
|
|
using BPA.SAAS.Manage.Core.System; |
|
|
|
using Furion.LinqBuilder; |
|
|
|
using Mapster.Utils; |
|
|
|
using StackExchange.Profiling.Internal; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
@@ -31,7 +32,7 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
if (App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value == null) |
|
|
|
return null; |
|
|
|
|
|
|
|
var AllMenus =await _db.Queryable<BPA_Menu>().Where(t => t.IsDeleted == 0).OrderBy(t => t.Sort).ToListAsync(); |
|
|
|
var AllMenus = await _db.Queryable<BPA_Menu>().OrderBy(t => t.Sort).ToListAsync(); |
|
|
|
|
|
|
|
var query = AllMenus.Where(t => t.Pid == "" || t.Pid == null); |
|
|
|
|
|
|
@@ -52,6 +53,7 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
Sort = t.Sort, |
|
|
|
Component = t.Component, |
|
|
|
Status = t.Status, |
|
|
|
IsAdmin = t.IsAdmin, |
|
|
|
Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeDtoOutput |
|
|
|
{ |
|
|
|
Id = x.Id, |
|
|
@@ -64,6 +66,7 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
Sort = x.Sort, |
|
|
|
Component = x.Component, |
|
|
|
Status = x.Status, |
|
|
|
IsAdmin = x.IsAdmin, |
|
|
|
Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeDtoOutput |
|
|
|
{ |
|
|
|
Id = y.Id.ToString(), |
|
|
@@ -76,6 +79,7 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
Sort = y.Sort, |
|
|
|
Component = y.Component, |
|
|
|
Status = y.Status, |
|
|
|
IsAdmin = y.IsAdmin, |
|
|
|
}).ToList() |
|
|
|
}).ToList() |
|
|
|
}).ToList(); |
|
|
@@ -89,17 +93,17 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> Add(MenuDtoInput input) |
|
|
|
{ |
|
|
|
var dicttypes = _db.Queryable<BPA_Menu>().Where(a => a.Code == input.Code && a.IsDeleted == 0).ToList(); |
|
|
|
if (dicttypes.Count() > 0) |
|
|
|
{ |
|
|
|
throw Oops.Oh("编码已存在"); |
|
|
|
} |
|
|
|
var dicttypes = _db.Queryable<BPA_Menu>().Where(a => a.Code == input.Code).ToList(); |
|
|
|
//if (dicttypes.Count() > 0) |
|
|
|
//{ |
|
|
|
// throw Oops.Oh("编码已存在"); |
|
|
|
//} |
|
|
|
if (input.Name.Length > 20) |
|
|
|
{ |
|
|
|
throw Oops.Oh("菜单名称过长"); |
|
|
|
} |
|
|
|
var menu = input.Adapt<BPA_Menu>(); |
|
|
|
return await _db.Insertable(menu).CallEntityMethod(t => t.Create()).ExecuteCommandAsync()> 0; |
|
|
|
return await _db.Insertable(menu).CallEntityMethod(t => t.Create()).ExecuteCommandAsync() > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -109,17 +113,18 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> Update(MenuDtoInput input) |
|
|
|
{ |
|
|
|
var menu = await _db.Queryable< BPA_Menu >().Where(x=>x.Id== input.Id).FirstAsync(); |
|
|
|
var menu = await _db.Queryable<BPA_Menu>().Where(x => x.Id == input.Id).FirstAsync(); |
|
|
|
//menu = input.Adapt<BPA_Menu>(); |
|
|
|
menu.Code = input.Code; |
|
|
|
menu.Component = input.Component; |
|
|
|
menu.Name= input.Name; |
|
|
|
menu.Pid= input.Pid; |
|
|
|
menu.Name = input.Name; |
|
|
|
menu.Pid = input.Pid; |
|
|
|
menu.Router = input.Router; |
|
|
|
menu.Remark= input.Remark; |
|
|
|
menu.Remark = input.Remark; |
|
|
|
menu.Sort = input.Sort; |
|
|
|
menu.Icon = input.Icon; |
|
|
|
return await _db.Updateable(menu).ExecuteCommandAsync()>0; |
|
|
|
menu.IsAdmin = input.IsAdmin; |
|
|
|
return await _db.Updateable(menu).ExecuteCommandAsync() > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -138,9 +143,9 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
{ |
|
|
|
x.IsDeleted = 1; |
|
|
|
}); |
|
|
|
var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); |
|
|
|
var res = await _db.Updateable(resEntitites).ExecuteCommandAsync(); |
|
|
|
_db.Ado.CommitTran(); |
|
|
|
return res>0; |
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
@@ -148,11 +153,11 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 查询菜单树 |
|
|
|
/// </summary> |
|
|
|
/// <param name="GetType"></param> |
|
|
|
/// <returns></returns> |
|
|
|
/// <summary> |
|
|
|
/// 查询菜单树 |
|
|
|
/// </summary> |
|
|
|
/// <param name="GetType"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<List<MenuTreeOutput>> MenuTree(string GetType) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrWhiteSpace(GetType) && GetType.ToLower() == "user") |
|
|
@@ -164,7 +169,7 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<BPA_Roles> dataRoles =await _db.Queryable<BPA_Roles>().Where(a => a.GroupId == GroupId).ToListAsync(); |
|
|
|
List<BPA_Roles> dataRoles = await _db.Queryable<BPA_Roles>().Where(a => a.GroupId == GroupId).ToListAsync(); |
|
|
|
if (dataRoles.Count() <= 0) |
|
|
|
{ |
|
|
|
return null; |
|
|
@@ -229,7 +234,7 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
/// 动态菜单(菜单树) |
|
|
|
/// </summary> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree() |
|
|
|
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree(int type) |
|
|
|
{ |
|
|
|
var UserId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; |
|
|
|
var IsAdmin = App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value; |
|
|
@@ -237,37 +242,74 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
|
|
|
|
if (UserId == null) |
|
|
|
return null; |
|
|
|
List<BPA_Menu> AllMenus = new List<BPA_Menu>(); |
|
|
|
List<BPA_Menu> AllMenus = await _db.Queryable<BPA_Menu>().OrderBy(t => t.Sort).ToListAsync(); |
|
|
|
List<BPA_Menu> ParnMenus = new(); |
|
|
|
if (IsAdmin == "1" && account == "admin") |
|
|
|
AllMenus =await _db.Queryable<BPA_Menu>().Where(t => t.IsDeleted == 0 && t.Status == 0).OrderBy(t => t.Sort).ToListAsync(); |
|
|
|
else |
|
|
|
AllMenus =await _db.Queryable<BPA_Menu>().LeftJoin<BPA_RoleMenu>((t, x) => t.Id == x.SysMenuId).LeftJoin<BPA_UserRole>((t, x, y) => x.SysRoleId == y.SysRoleId) |
|
|
|
.Where((t, x, y) => y.SysUserId == UserId && t.Status == 0).Select(t => t).ToListAsync(); |
|
|
|
//菜单去重 |
|
|
|
AllMenus = AllMenus.Where((x, i) => AllMenus.FindIndex(z => z.Id == x.Id) == i).ToList(); |
|
|
|
var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").OrderBy(t => t.Sort).Select(t => new MenuRouteDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = t.Component, |
|
|
|
Icon = t.Icon, |
|
|
|
Name = t.Name, |
|
|
|
Path = t.Router, |
|
|
|
Routes = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput |
|
|
|
//ParnMenus = await _db.Queryable<BPA_Menu>().Where(t => t.IsAdmin == 1).OrderBy(t => t.Sort).ToListAsync(); |
|
|
|
var childMenus = await _db.Queryable<BPA_Menu>().Where(t => t.IsAdmin == 1 && t.Type == 3).OrderBy(t => t.Sort).ToListAsync(); |
|
|
|
var parnids= childMenus.Select(t => t.Pid).ToList(); |
|
|
|
var parnlist = _db.Queryable<BPA_Menu>().Where(x => parnids.Contains(x.Id)).Select(t => new MenuRouteDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = x.Component, |
|
|
|
Name = x.Name, |
|
|
|
Path = x.Router, |
|
|
|
Routes = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuRouteChildDtoOutput |
|
|
|
Component = t.Component, |
|
|
|
Icon = t.Icon, |
|
|
|
Name = t.Name, |
|
|
|
Path = t.Router, |
|
|
|
Routes= AllMenus.Where(p=>p.Id==t.Pid).Select(t => new MenuRouteChildDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = y.Component, |
|
|
|
Name = y.Name, |
|
|
|
Path = y.Router |
|
|
|
Component = t.Component, |
|
|
|
Name = t.Name, |
|
|
|
Path = t.Router, |
|
|
|
}).ToList() |
|
|
|
}).ToList() |
|
|
|
}).ToList(); |
|
|
|
return data; |
|
|
|
}).ToList(); |
|
|
|
var list=parnlist.Select(t => new MenuRouteDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = t.Component, |
|
|
|
Icon = t.Icon, |
|
|
|
Name = t.Name, |
|
|
|
Path = t.Path, |
|
|
|
Routes = childMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = x.Component, |
|
|
|
Name = x.Name, |
|
|
|
Path = x.Router, |
|
|
|
Routes = childMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = x.Component, |
|
|
|
Name = x.Name, |
|
|
|
Path = x.Router, |
|
|
|
}).ToList() |
|
|
|
}).ToList() |
|
|
|
}).ToList(); |
|
|
|
return list; |
|
|
|
} |
|
|
|
else{ |
|
|
|
var childMenus = await _db.Queryable<BPA_Menu>().Where(t => t.IsAdmin == 0 && (t.Type == 3 || t.Type == type)).OrderBy(t => t.Sort).ToListAsync(); |
|
|
|
var parnids = childMenus.Select(t => t.Pid).ToList(); |
|
|
|
var parnlist = _db.Queryable<BPA_Menu>().Where(x => parnids.Contains(x.Id)).ToList(); |
|
|
|
var list = parnlist.OrderBy(t => t.Sort).Select(t => new MenuRouteDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = t.Component, |
|
|
|
Icon = t.Icon, |
|
|
|
Name = t.Name, |
|
|
|
Path = t.Router, |
|
|
|
Routes = childMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = x.Component, |
|
|
|
Name = x.Name, |
|
|
|
Path = x.Router, |
|
|
|
}).ToList() |
|
|
|
}).ToList(); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 启用 |
|
|
|