Пример #1
0
        /// <summary>
        /// 获取所有菜单
        /// </summary>
        /// <returns></returns>
        public DataGridResult GetMenu(SearchItem item)
        {
            string sql = @" select aa.id,
                                    aa.pid,
                                    ab.id menuid,
                                    aa.name,
                                    ab.url url,
                                    ab.platformid
                               from menutree aa, menu ab
                              where  aa.menuid = ab.id(+)  ";

            if (int.Parse(employee.Id) > 0)
            {
                sql += @" and (aa.menuid in (
                                                   select a.id
                                                     from menu a,
                                                           menuqx        b,
                                                           USER_ROLE c
                                                    where a.id = b.menuid
                                                      and b.roleid = c.roleid
                                                      and c.userid = " + employee.Id + @") or
                                    aa.menuid is null)";
            }

            sql += " order by aa.id  ";
            DataTable             dt           = DbHelper.ExecuteTable(sql);
            List <PLATFORMEntity> PlatFormList = DbHelper.SelectList(new PLATFORMEntity());

            foreach (DataRow dr in dt.Rows)
            {
                string url = dr["URL"].ToString();
                dr["PLATFORMID"].ToString().TryToInt(PlatFormId =>
                {
                    var pt = PlatFormList.Where(a => a.ID == PlatFormId.ToString()).FirstOrDefault(a => url.IsRegexMatch(a.MATCH));
                    if (pt != null)
                    {
                        dr["URL"] = pt.DOMAIN + url;
                    }
                });
            }
            return(new DataGridResult(dt, 0));
        }
Пример #2
0
        public UIResult GetMenuNew(MENUEntity data, string host)
        {
            List <MENUTREEModule> MENU_GROUPList = new List <MENUTREEModule>();
            List <PLATFORMEntity> PlatFormList   = DbHelper
                                                   .SelectList(new PLATFORMEntity()
            {
                ID = data.PLATFORMID
            })
                                                   .GroupBy(a => a.ID)
                                                   .Select(a =>
            {
                var pt = a.FirstOrDefault(b => host.IsRegexMatch(b.MATCH));
                if (pt == null)
                {
                    pt = a.First();
                }
                return(new PLATFORMEntity()
                {
                    ID = a.Key,
                    DOMAIN = pt.DOMAIN
                });
            }).ToList();

            //子系统要多传递参数回来
            string sqlgroup = @" SELECT MODULECODE ID,MODULENAME NAME,ICON FROM USERMODULE WHERE LENGTH(MODULECODE)=4  and ENABLE_FLAG=1";

            if (int.Parse(employee.Id) > 0)
            {
                sqlgroup += @" and MODULECODE in (
                                        SELECT DISTINCT SUBSTR(A.MODULECODE,1,4) FROM USERMODULE A,ROLE_MENU B,USER_ROLE C
                                        WHERE A.MENUID=B.MENUID AND B.ROLEID=C.ROLEID
                                        AND C.USERID=" + employee.Id + ")";
            }
            if (int.Parse(data.PLATFORMID) == 1)
            {
                sqlgroup += @" and MODULECODE like '02%'";
            }
            if (int.Parse(data.PLATFORMID) == 2)
            {
                sqlgroup += @" and MODULECODE like '05%'";
            }
            sqlgroup += @" ORDER BY MODULECODE";
            DataTable menuGroup = DbHelper.ExecuteTable(sqlgroup);


            if (menuGroup.IsNotNull())
            {
                MENU_GROUPList = menuGroup.ToList <MENUTREEModule>();

                foreach (var menuGr in MENU_GROUPList)
                {
                    string sql = @" select aa.moduleid id,
                                    ab.id menuid,
                                    aa.modulename name,
                                    ab.url url,
                                    ab.platformid
                               from usermodule aa, menu ab
                              where  aa.menuid = ab.id and LENGTH(aa.MODULECODE)=6 and aa.ENABLE_FLAG=1
                                and aa.modulecode like  '" + menuGr.ID + "%'";
                    if (int.Parse(employee.Id) > 0)
                    {
                        //因菜单树型权限 按扭权限不全选时 对应菜单未保存到ROLE_MENU
                        //暂改成 由按扭权单id截取6位关联菜单id   by wangkx 20190705
                        //b.menuid 改为 to_number(substr( to_char(b.menuid),1,6))
                        // by DZK  20190716   ID取6位引起crm找不到子菜单,根据PLATFORMID 查询
                        if (int.Parse(data.PLATFORMID) == 1)
                        {
                            sql += @" and aa.menuid in (
                                                   select a.id
                                                     from menu a,
                                                           ROLE_MENU b,
                                                           USER_ROLE c
                                                    where a.id = to_number(substr( to_char(b.menuid),1,6))  
                                                      and b.roleid = c.roleid
                                                      and c.userid = " + employee.Id + @" or
                                    aa.menuid is null)";
                        }
                        else
                        {
                            sql += @" and aa.menuid in (
                                                   select a.id
                                                     from menu a,
                                                           ROLE_MENU b,
                                                           USER_ROLE c
                                                    where a.id = b.menuid 
                                                      and b.roleid = c.roleid
                                                      and c.userid = " + employee.Id + @" or
                                    aa.menuid is null)";
                        }
                    }

                    sql += " order by aa.modulecode  ";
                    DataTable menu = DbHelper.ExecuteTable(sql);
                    foreach (DataRow dr in menu.Rows)
                    {
                        string url = dr["URL"].ToString();
                        dr["PLATFORMID"].ToString().TryToInt(PlatFormId =>
                        {
                            var pt = PlatFormList.FirstOrDefault(a => a.ID == PlatFormId.ToString());
                            if (pt != null)
                            {
                                dr["URL"] = pt.DOMAIN + url;
                            }
                        });
                    }
                    menuGr.MENUList = menu.ToList <MENUEntity>();
                }
                ;
            }
            ;
            return(new UIResult(new
            {
                MENU = MENU_GROUPList
            }));
        }