Exemplo n.º 1
0
        public async Task <ApiResult> GetAllOrg()
        {
            ApiResult ret = new ApiResult();

            try
            {
                List <OrgNodeType> nodeTypes = await _orgRepo.ListNodeType();

                List <OrgTree> nodes_all = await _orgRepo.ListAllOrgNode();

                // 获取顶级节点
                List <OrgTree> nodes_org = nodes_all.Where(c => c.ParentID == null).ToList();
                // 解析单个组织
                List <object> orgs = new List <object>();
                foreach (OrgTree node in nodes_org)
                {
                    if (!node.IsDel)
                    {
                        var obj = _parseOrgTree(node, nodes_all, nodeTypes);
                        orgs.Add(obj);
                    }
                }
                ret.code = Code.Success;
                ret.data = orgs;
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
            }

            return(ret);
        }