from atdd.PcPost import PcPost class PulbicOrg(PcPost): url_ListChildren = "/Contact/Apicp/Department/ListChildren" # 获取顶级部门的ID def get_top_org(self): url = "/Contact/Apicp/Department/List" data = { "_identifier": 'contact', "limit": 99999 } result = self.PcPost(url,data) top_dpId = result['result']['list'][0]['dpId'] return top_dpId # 查找某一个部门以及其子部门的dpId,以list格式返回 def get_all_dpId(self,dpParentId): data = { "dpParentId":dpParentId } result = self.PcPost(self.url_ListChildren,data) orglist = result['result']['list'] # 组织列表的list信息 dpIdList = [] for i in range(len(orglist)): dpId = orglist[i]['dpId'].split() # 将dpId加入到dpIdList中 dpIdList[len(dpIdList):len(dpIdList)] = dpId return dpIdList # 获取组织下的人员总数 def get_org_user_total(self,dpParentId): data = { "dpParentId": dpParentId } result = self.PcPost(self.url_ListChildren,data) user_total = result['result']['list'][0]['user_total'] return user_total