public async Task <IActionResult> GetRoleMenuAsync([FromBody] GetRoleMenuRequestDto request) { GrantRoleBiz grantRoleBiz = new GrantRoleBiz(); var roleRights = await grantRoleBiz.GetRoleRightAsync(request.RoleGuid); return(Success(roleRights)); }
public async Task <IActionResult> SaveRoleMenuAsync([FromBody] AddRoleMenuRequestDto request) { GrantRoleBiz grantRoleBiz = new GrantRoleBiz(); var roleRights = await grantRoleBiz.GetRoleRightAsync(request.RoleGuid); //提交中数据中 数据库存在的 var dbRoleRights = roleRights.Where(a => request.RightGuids.Contains(a)); var addRoleRights = request.RightGuids.Except(dbRoleRights).ToArray(); var deleteRoleRights = roleRights.Except(dbRoleRights).ToArray(); var result = await grantRoleBiz.SaveRoleMenuAsync(addRoleRights.Select(a => new GrantRoleModel { RoleGuid = request.RoleGuid, RightGuid = a, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty, GrantGuid = Guid.NewGuid().ToString("N") }), request.RoleGuid, deleteRoleRights); if (!result) { return(Failed(ErrorCode.UserData, "删除失败")); } return(Success()); }