Пример #1
0
        /// <summary>
        /// 根据当前登录用户所属组织,查询组织树
        /// </summary>
        /// <param name="rootOrgId">当前登录用户的组织id</param>
        /// <param name="orgNameLike">组织名称参数</param>
        /// <param name="orgStatus">组织状态参数</param>
        /// <returns>组织列表</returns>
        public MsgModel GetOrgTreeById(int rootOrgId, string orgNameLike, bool?orgStatus)
        {
            MsgModel msg = new MsgModel()
            {
                isok    = true,
                message = "查询成功!"
            };
            List <sys_org>    sysOrgs     = _mySystemService.SelectOrgTree(rootOrgId, orgNameLike, orgStatus);
            List <SysOrgNode> sysOrgNodes = new List <SysOrgNode>();

            foreach (sys_org sys_org in sysOrgs)
            {
                SysOrgNode sysOrgNode = sys_org.BuildAdapter().AdaptToType <SysOrgNode>();
                sysOrgNodes.Add(sysOrgNode);
            }
            if (!string.IsNullOrEmpty(orgNameLike))
            {
                //根据组织名称查询,返回平面列表
                msg.data = sysOrgNodes;
                return(msg);
            }
            else
            {
                //否则返回树型结构列表
                msg.data = DataTreeUtil <SysOrgNode, long> .BuildTree(sysOrgNodes, rootOrgId);

                return(msg);
            }
        }
Пример #2
0
        /// <summary>
        /// 根据某用户的用户名查询该用户可以访问的菜单项(系统左侧边栏菜单)
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public MsgModel GetMenuTreeByUsername(string username)
        {
            MsgModel msg = new MsgModel()
            {
                isok    = true,
                message = "查询成功!"
            };
            List <sys_menu> sysMenus = _mySystemService.SelectMenuByUserName(username);

            if (sysMenus.Count > 0)
            {
                int rootMenuId = sysMenus.First().id;

                List <SysMenuNode> sysMenuNodes = new List <SysMenuNode>();
                foreach (sys_menu sys_menu in sysMenus)
                {
                    SysMenuNode sysMenuNode = sys_menu.BuildAdapter().AdaptToType <SysMenuNode>();
                    sysMenuNodes.Add(sysMenuNode);
                }
                msg.data = DataTreeUtil <SysMenuNode, int> .BuildTreeWithoutRoot(sysMenuNodes, rootMenuId);

                return(msg);
            }
            msg.data = new List <SysMenuNode>();
            return(msg);
        }
Пример #3
0
        public MsgModel GetApiTreeById(string apiNameLike, bool apiStatus)
        {
            MsgModel msg = new MsgModel
            {
                isok    = true,
                message = "查询成功!"
            };
            //查找level=1的API节点,即:根节点
            sys_api rootSysApi = _baseService.GetModels(s => s.level == 1).Single();

            if (rootSysApi != null)
            {
                int               rootApiId   = rootSysApi.id;
                List <sys_api>    sysApis     = _mySystemService.SelectApiTree(rootApiId, apiNameLike, apiStatus);
                List <SysApiNode> sysApiNodes = new List <SysApiNode>();
                foreach (sys_api sys_Api in sysApis)
                {
                    SysApiNode sysApiNode = sys_Api.BuildAdapter().AdaptToType <SysApiNode>();
                    sysApiNodes.Add(sysApiNode);
                }

                if (!string.IsNullOrEmpty(apiNameLike))
                {
                    //根据api名称等查询会破坏树形结构,返回平面列表
                    msg.data = sysApiNodes;
                    return(msg);
                }

                //否则返回树型结构列表
                msg.data = DataTreeUtil <SysApiNode, long> .BuildTree(sysApiNodes, rootApiId);

                return(msg);
            }
            return(msg);
        }
Пример #4
0
        /// <summary>
        /// 菜单管理:根据查询条件查询树形结构菜单列表
        /// </summary>
        /// <param name="menuNameLike">菜单名称</param>
        /// <param name="menuStatus">菜单可用状态</param>
        /// <returns>菜单列表或树形列表</returns>
        public MsgModel GetMenuTree(string menuNameLike, bool?menuStatus)
        {
            MsgModel msg = new MsgModel
            {
                message = "查询成功!",
                isok    = true
            };

            //保证数据库里面level=1的节点只有一个,根节点
            sys_menu rootSysMenu = _baseSysMenuService.GetModels(a => a.level == 1).SingleOrDefault();

            if (rootSysMenu != null)
            {
                int                rootMenuId   = rootSysMenu.id;
                List <sys_menu>    sysMenus     = _mySystemService.SelectMenuTree(rootMenuId, menuNameLike, menuStatus);
                List <SysMenuNode> sysMenuNodes = new List <SysMenuNode>();
                foreach (sys_menu sys_menu in sysMenus)
                {
                    SysMenuNode sysMenuNode = sys_menu.BuildAdapter().AdaptToType <SysMenuNode>();
                    sysMenuNodes.Add(sysMenuNode);
                }
                if (!string.IsNullOrEmpty(menuNameLike))
                {
                    // 根据菜单名称查询,返回平面列表
                    msg.data = sysMenuNodes;
                    return(msg);
                }
                else
                {
                    // 否则返回菜单的树型结构列表
                    msg.data = DataTreeUtil <SysMenuNode, int> .BuildTree(sysMenuNodes, rootMenuId);

                    return(msg);
                }
            }
            else
            {
                // "请先在数据库内为菜单配置一个分类的根节点,level=1"
                msg.message = "请先在数据库内为菜单配置一个分类的根节点,level=1";
                msg.data    = new List <SysMenuNode>();
                return(msg);
            }
        }