/// <summary> /// 获取部门 /// </summary> /// <param name="accessToken"></param> /// <param name="partyid">部门编号集合</param> /// <returns></returns> static List <DeptSelector> GetDepartmentsAll(string accessToken, List <int> partyid) { if (partyid == null || partyid.Count == 0) { return(null); } List <DeptSelector> depts = new List <DeptSelector>(); Department department = new Department(); foreach (int _partyid in partyid) { var dept = department.List(accessToken, _partyid); var items = DeptSelector.ConvertTo(dept).ToList(); if (items != null && items.Count > 0) { var item = items.FirstOrDefault(e => e.Id == _partyid.ToString()); if (item != null) { item.Special = true;// 标识为顶级节点 } depts.AddRange(items); } } return(depts); }
/// <summary> /// 获取部门 /// </summary> /// <param name="accessToken"></param> /// <param name="partyid">部门编号集合</param> /// <returns></returns> static List <DeptSelector> GetDepartments(string accessToken, List <int> partyid, int deptid = -1) { if (partyid == null || partyid.Count == 0) { return(null); } List <DeptSelector> depts = new List <DeptSelector>(); Department department = new Department(); foreach (int _partyid in partyid) { var dept = department.List(accessToken, _partyid);// 部门信息 if (dept != null && dept.errcode == 0) { if (deptid == -1) { Department.RequestBody body = dept.department.FirstOrDefault(e => e.id == _partyid); var item = DeptSelector.ConvertTo(body, true); if (item != null) { depts.Add(item); } } else { var bodys = dept.department.Where(e => e.parentid == deptid).ToList(); var items = DeptSelector.ConvertTo(bodys).ToList(); if (items != null && items.Count > 0) { depts.AddRange(items); } } } } return(depts); }