|
|
@@ -402,8 +402,18 @@ |
|
|
|
public async Task<bool> AddRoleModule(RoleModuleAddInput input) |
|
|
|
{ |
|
|
|
List<RoleModuleEntity> entitys = new(); |
|
|
|
var moduleList =await _dbContext.Queryable<ModuleEntity>().ToListAsync(); |
|
|
|
var parentId = input.ModuleIds.Where(x=>x.ParentId!="").GroupBy(x => x.ParentId).ToList(); |
|
|
|
foreach (var item in parentId) |
|
|
|
{ |
|
|
|
if (input.ModuleIds.FirstOrDefault(x=>x.ModuleId==item.Key && x.ParentId=="")==null) |
|
|
|
{ |
|
|
|
input.ModuleIds.Add(new RoleModuleDto { ModuleId = item.Key, ParentId = "", RoleId = input.RoleId }); |
|
|
|
} |
|
|
|
} |
|
|
|
foreach (var item in input.ModuleIds) |
|
|
|
{ |
|
|
|
|
|
|
|
RoleModuleEntity entity = new() |
|
|
|
{ |
|
|
|
ModuleId = item.ModuleId, |
|
|
@@ -433,7 +443,7 @@ |
|
|
|
[HttpGet] |
|
|
|
public async Task<List<RoleModuleOutput>> RoleModuleList(string RoleId) |
|
|
|
{ |
|
|
|
var entitys = await _dbContext.Queryable<RoleModuleEntity>().Where(x => x.RoleId == RoleId).ToListAsync(); |
|
|
|
var entitys = await _dbContext.Queryable<RoleModuleEntity>().Where(x => x.RoleId == RoleId&&x.ParentId!="").ToListAsync(); |
|
|
|
var output = entitys.Adapt<List<RoleModuleOutput>>(); |
|
|
|
return output; |
|
|
|
} |
|
|
|