123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using Bowin.Common.Linq;
- using YLShipBuildLandMap.Entity;
- using YLShipBuildLandMap.Entity.ViewModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- namespace YLShipBuildLandMap.Services.SystemSetting
- {
- public class MenuService : IMenuService
- {
- private YLShipBuildLandMapContext DbContext { get; set; }
- public MenuService(YLShipBuildLandMapContext dbContext)
- {
- DbContext = dbContext;
- }
- private IQueryable<SysMenu> GetMenuByUser(
- Expression<Func<SysMenu, bool>> menuDefineExp,
- Expression<Func<SysUser, bool>> userExp)
- {
- var userFunc = userExp;
- var menuDefineFunc = menuDefineExp;
- var iqResult = (
- from m in this.DbContext.SysMenu.Where(menuDefineExp)
- where m.FunctionCode == null || (
- from u in this.DbContext.SysUser.Where(userExp)
- from r in u.SysUserSysRole
- from f in r.Role.SysRoleSysFunctionCode
- where f.FunctionCode == m.FunctionCode
- select 1
- ).Any()
- select m
- );
- return iqResult.OrderBy(x => x.OrderNo).ThenBy(x => x.MenuNo);
- }
- public List<SysMenu> GetMenuByUserID(Guid userID)
- {
- Expression<Func<SysMenu, bool>> menuDefineExp = (x => x.RecordStatus >= 1);
- Expression<Func<SysUser, bool>> userExp = (x => x.UserId == userID);
- return GetMenuByUser(menuDefineExp, userExp).ToList();
- }
- }
- }
|