12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.DataLogic.SystemDAL
- {
- public class ContextMenuDAL
- {
- public RoleRepository RoleRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public ContextMenuRepository ContextMenuRepository { get; set; }
- /// <summary>
- /// 根据对应的条件查询相应页面的权限信息
- /// </summary>
- /// <param name="menuNo"></param>
- /// <param name="formClass"></param>
- /// <param name="userID"></param>
- /// <param name="roleID"></param>
- /// <returns></returns>
- public IQueryable<Sys_ContextMenu> GetContextMenuListByUserAndRoleID(string menuNo, string formClass, Guid userID, Guid? roleID)
- {
- var query = from cm in ContextMenuRepository.GetList(x => x.RecordStatus >= (int)SYS_STATUS.USABLE)
- from tr in cm.Sys_FunctionCode.Sys_Role.Where(x => x.RecordStatus >= (int)SYS_STATUS.USABLE).DefaultIfEmpty()
- from ur in tr.Sys_User.DefaultIfEmpty()
- where
- (cm.FunctionCode == null || !cm.IsNeedPrivilege || (((ur != null) ? ur.UserID : Guid.Empty) == userID
- && (roleID == null || tr.RoleID == roleID)))
- && cm.MenuNo == menuNo
- && cm.FormClass == formClass
- select cm;
- return query.Distinct();
- }
- }
- }
|