/// <summary> /// 获取父ids /// </summary> /// <param name="groups">组织机构列表</param> /// <param name="parentId">当前授信主体父id</param> /// <returns></returns> private List<int> GetParentIds(List<Group> groups, int parentId) { List<int> parentIds = new List<int>(); parentIds.Add(parentId); Group group = groups.Where(g => g.Id == parentId).FirstOrDefault(); if (group != null) { parentIds.Add(group.Id); if (group.ParentId != 0) { GetParentIds(groups, group.ParentId); } } return parentIds; }
List<Group> Groups = new List<Group>(); object[] objs = MappingEngine.Filter(typeof(Group), null); foreach (var obj in objs) { Group group = obj as Group; Groups.Add(group); } Group organization = Groups.Where(g => g.Id == this.OrganizationId).FirstOrDefault(); List<int> ids = GetParentIds(Groups, organization.ParentId); ids.Add(organization.Id); if (ids.Contains(credit.Grantor)) { //通过验证 } else { throw new Exception("责任主体非授信主体或其下级机构。"); }
时间: 2024-10-09 08:00:10