|
|
@@ -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<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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |