欢迎页
ok-admin框架,第二天系统主页
@{
Layout = null;
}
后台代码:
///
/// 角色菜单权限
///
///
public ActionResult RoleMenu()
{
//查询结果映射到实体类RoleMenu中;
YuanGongDb dbcontext = new YuanGongDb();
int RID =int.Parse(Session["RID"].ToString());//获取登录的角色ID
var roleMenu = dbcontext.RoleInMenu.Where(o => o.Rid == RID).ToList();
var Menu = dbcontext.SysMenu.Where(o => o.pid == 0).ToList();
var menu1 = Menu.OrderBy(o=>o.sort).ToList();
var data = roleMenu.Join(Menu, o => o.Mid, p => p.id, (o, p) =>
new RoleMenu()
{
id = p.id,
name = p.name,
url = p.url,
type = p.type,
pid = p.pid
}
).ToList();
//var data = (from u in dbcontext.RoleInMenu
// where u.Rid == RID
// join p in dbcontext.SysMenu on u.Mid equals p.id
// select new RoleMenu
// { id = p.id, name = p.name, url = p.url, type = p.type, pid = p.pid }).ToList();
return Json(data, JsonRequestBehavior.AllowGet);
}