1234567891011121314151617181920212223242526272829303132333435 |
- using ERP.Core.Entities;
- using ERP.Framework.WebApi;
- namespace ERP.Core.Repositorys
- {
- public class SysMenuRepository : BaseRepository<SysMenu, CoreDbContext>
- {
- public SysMenuRepository(CoreDbContext context) : base(context)
- {
- }
- public List<SysMenu> SelectMenuListByUserId(long userId)
- {
- var q = from m in Context.Set<SysMenu>()
- join rm in Context.Set<SysRoleMenu>() on m.Id equals rm.RoleId
- join r in Context.Set<SysRole>() on rm.RoleId equals r.Id
- join ru in Context.Set<SysUserRole>() on r.Id equals ru.RoleId
- join u in Context.Set<SysUser>() on ru.UserId equals u.Id
- where u.Id == userId
- select m;
- return q.ToList();
- }
- public List<string> SelectPermissionsByRoleIds(List<long> roleIds)
- {
- var q = from rm in Context.Set<SysRoleMenu>()
- join m in Context.Set<SysMenu>() on rm.MenuId equals m.Id
- where roleIds.Contains(rm.RoleId)
- select m.Permission;
- return q.ToList();
- }
- }
- }
|