コード例 #1
0
        public IHttpActionResult GetMenuByRole(M m)
        {
            try
            {
                if (m != null && m.roles.Count > 0)
                {
                    string role = m.roles[0];
                    //全部菜单
                    var menus = Db.Context(APP.DB_DEFAULT_CONN_NAME).Sql(string.Format(@"select * from dbo.menutab where isnull(isclosed,0) =0 order by parentid,sort")).QueryMany <Menu>();

                    //全部meta
                    var metas = Db.Context(APP.DB_DEFAULT_CONN_NAME).Sql(string.Format(@"select * from dbo.menumetatab")).QueryMany <Meta>();

                    //待返回菜单数据格式
                    List <Menu> menulist = new List <Menu>();
                    menulist = CommonMethod.BuildMenuMeta(menus, metas);
                    menulist = CommonMethod.BuildMenuChildren(menus);
                    return(Success("success", menulist));
                }
                else
                {
                    return(Error("未能获取到用户角色!"));
                }
            }
            catch (Exception e)
            {
                return(Exception(e.Message));
            }
        }
コード例 #2
0
        public IHttpActionResult GetMenuList()
        {
            //全部菜单
            var menus = Db.Context(APP.DB_DEFAULT_CONN_NAME).Sql(string.Format(@"select * from dbo.menutab where 1=1 order by parentid,sort")).QueryMany <Menu>();

            //全部meta
            var metas = Db.Context(APP.DB_DEFAULT_CONN_NAME).Sql(string.Format(@"select * from dbo.menumetatab")).QueryMany <Meta>();

            //待返回菜单数据格式
            List <Menu> menulist = new List <Menu>();

            menulist = CommonMethod.BuildMenuMeta(menus, metas);
            menulist = CommonMethod.BuildMenuChildren(menus);
            return(Success("success", menulist));
        }