public async Task <PagedResultDto <YaeherModule> > YaeherModulePage(YaeherModuleIn YaeherModulefo)
        {
            //初步过滤
            var query = _repository.GetAll().OrderByDescending(a => a.CreatedOn).Where(YaeherModulefo.Expression);

            // 根据主菜单查询所有子菜单
            if (YaeherModulefo.UpperLevel > -1 && YaeherModulefo.UpperLevel != 0)
            {
                query = query.Where(a => a.ParentId == YaeherModulefo.UpperLevel || a.Id == YaeherModulefo.UpperLevel);
            }
            //  查询所有主菜单
            if (YaeherModulefo.UpperLevel == -1)
            {
                query = query.Where(a => a.ParentId == 0);
            }
            // 查询所有菜单
            if (YaeherModulefo.UpperLevel == -2)
            {
                query = query.Where(a => a.ParentId >= 0);
            }
            //获取总数
            var tasksCount = query.Count();
            //获取总数
            var totalpage        = tasksCount / YaeherModulefo.MaxResultCount;
            var YaeherModuleList = await query.PageBy(YaeherModulefo.SkipTotal, YaeherModulefo.MaxResultCount).ToListAsync();

            return(new PagedResultDto <YaeherModule>(tasksCount, YaeherModuleList.MapTo <List <YaeherModule> >()));
        }
Exemple #2
0
        public async Task <ObjectResultModule> YaeherRoleModuleList([FromBody] YaeherRoleModuleIn YaeherRoleModuleInfo)
        {
            if (!Commons.CheckSecret(YaeherRoleModuleInfo.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var userid = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;

            YaeherRoleModuleInfo.AndAlso(a => a.IsDelete == false);
            var values = await _yaeherRoleModuleService.YaeherRoleModuleList(YaeherRoleModuleInfo);

            YaeherModuleIn yaeherModuleIn = new YaeherModuleIn();

            yaeherModuleIn.AndAlso(a => a.IsDelete == false && a.Enabled == true);
            var ModuleList = await _yaeherModuleService.YaeherModule(yaeherModuleIn);

            var RoleAndModuleList = from Modules in ModuleList
                                    join RoleAndModule in values on Modules.Id equals RoleAndModule.ModuleId
                                    select new { Modules.Id, Modules.ParentId, Modules.Names, Modules.LinkUrls, Modules.Areas,
                                                 Modules.Controllers, Modules.Actionss, Modules.Icons, Modules.Codes, Modules.OrderSort,
                                                 Modules.Description, Modules.IsMenu,
                                                 RoleAndModule.RoleId };

            if (RoleAndModuleList.Count() == 0)
            {
                this.ObjectResultModule.StatusCode = 204;
                this.ObjectResultModule.Message    = "NoContent";
                this.ObjectResultModule.Object     = "";
            }
            else
            {
                YaeherRoleModuleJSon yaeherRoleModuleJSon = new YaeherRoleModuleJSon();
                foreach (var RoleModuls in RoleAndModuleList)
                {
                    yaeherRoleModuleJSon.ModuleId += RoleModuls.Id + ",";
                    yaeherRoleModuleJSon.RoleId    = RoleModuls.RoleId;
                }
                this.ObjectResultModule.Object     = yaeherRoleModuleJSon;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "YaeherRoleModuleList",
                OperContent = JsonHelper.ToJson(YaeherRoleModuleInfo),
                OperType    = "YaeherRoleModuleList",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }
        public async Task <IList <YaeherModuleNode> > YaeherModuleList(YaeherModuleIn YaeherModulefo)
        {
            #region
            //var query = _repository.GetAll().OrderByDescending(a => a.CreatedOn).Where(YaeherModulefo.Expression);
            //// 根据主菜单查询所有子菜单
            //if (YaeherModulefo.UpperLevel > -1 && YaeherModulefo.UpperLevel != 0)
            //{
            //    query = query.Where(a => a.ParentId == YaeherModulefo.UpperLevel || a.Id == YaeherModulefo.UpperLevel);
            //}
            ////  查询所有主菜单
            //if (YaeherModulefo.UpperLevel == -1)
            //{
            //    query = query.Where(a => a.ParentId ==0);
            //}
            //// 查询所有菜单
            //if (YaeherModulefo.UpperLevel == -2)
            //{
            //    query = query.Where(a => a.ParentId >= 0);
            //}
            #endregion
            var query = await _repository.GetAll().Where(YaeherModulefo.Expression).ToListAsync();

            List <YaeherModuleNode> yaeherModuleNodes = new List <YaeherModuleNode>();
            List <YaeherModule>     ModuleNode        = query.Where(a => a.ParentId == 0).ToList();
            foreach (var item in ModuleNode)
            {
                YaeherModuleNode yaeherModuleNode = new YaeherModuleNode();
                yaeherModuleNode.Id          = item.Id;
                yaeherModuleNode.ParentId    = item.ParentId;
                yaeherModuleNode.Names       = item.Names;
                yaeherModuleNode.LinkUrls    = item.LinkUrls;
                yaeherModuleNode.Areas       = item.Areas;
                yaeherModuleNode.Controllers = item.Controllers;
                yaeherModuleNode.Actionss    = item.Actionss;
                yaeherModuleNode.Icons       = item.Icons;
                yaeherModuleNode.Codes       = item.Codes;
                yaeherModuleNode.OrderSort   = item.OrderSort;
                yaeherModuleNode.Description = item.Description;
                yaeherModuleNode.IsMenu      = item.IsMenu;
                yaeherModuleNode.Enabled     = item.Enabled;
                yaeherModuleNode.children    = GetChild(query.ToList(), item.Id);
                yaeherModuleNodes.Add(yaeherModuleNode);
            }
            return(yaeherModuleNodes.OrderBy(a => a.OrderSort).ToList());
        }
Exemple #4
0
        public async Task <ObjectResultModule> YaeherModuleUpperList([FromBody] YaeherModuleIn YaeherModuleInfo)
        {
            if (!Commons.CheckSecret(YaeherModuleInfo.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var userid = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;

            YaeherModuleInfo.AndAlso(a => a.IsDelete == false);
            YaeherModuleInfo.AndAlso(a => a.Enabled == true);
            var values = await _yaeherModuleService.YaeherModuleList(YaeherModuleInfo);

            if (values.Count == 0)
            {
                this.ObjectResultModule.StatusCode = 204;
                this.ObjectResultModule.Message    = "NoContent";
                this.ObjectResultModule.Object     = "";
            }
            else
            {
                this.ObjectResultModule.Object     = values;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "YaeherModuleUpperList",
                OperContent = JsonHelper.ToJson(YaeherModuleInfo),
                OperType    = "YaeherModuleUpperList",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }
Exemple #5
0
        public async Task <ObjectResultModule> YaeherModuleById([FromBody] YaeherModuleIn YaeherModuleInfo)
        {
            if (!Commons.CheckSecret(YaeherModuleInfo.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var userid = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;
            var values = await _yaeherModuleService.YaeherModuleByID(YaeherModuleInfo.Id);

            if (values == null)
            {
                this.ObjectResultModule.StatusCode = 404;
                this.ObjectResultModule.Message    = "NotFound";
            }
            else
            {
                this.ObjectResultModule.Object     = values;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "YaeherModuleById",
                OperContent = JsonHelper.ToJson(YaeherModuleInfo),
                OperType    = "YaeherModuleById",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }
Exemple #6
0
        public async Task <ObjectResultModule> YaeherModuleList([FromBody] YaeherModuleIn YaeherModuleInfo)
        {
            if (!Commons.CheckSecret(YaeherModuleInfo.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var      userid    = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;
            DateTime StartTime = new DateTime();
            DateTime EndTime   = new DateTime();

            if (!string.IsNullOrEmpty(YaeherModuleInfo.StartTime))
            {
                StartTime = DateTime.Parse(YaeherModuleInfo.StartTime);
                if (string.IsNullOrEmpty(YaeherModuleInfo.EndTime))
                {
                    YaeherModuleInfo.EndTime = DateTime.Now.ToString("yyyy-MM-dd");
                }
            }
            if (!string.IsNullOrEmpty(YaeherModuleInfo.EndTime))
            {
                EndTime = DateTime.Parse(YaeherModuleInfo.EndTime);
            }
            if (!string.IsNullOrEmpty(YaeherModuleInfo.StartTime))
            {
                YaeherModuleInfo.AndAlso(t => t.CreatedOn >= StartTime);
                YaeherModuleInfo.AndAlso(t => t.CreatedOn < EndTime.AddDays(+1));
            }
            if (!string.IsNullOrEmpty(YaeherModuleInfo.KeyWord))
            {
                YaeherModuleInfo.AndAlso(t => t.Names.Contains(YaeherModuleInfo.KeyWord) ||
                                         t.Actionss.Contains(YaeherModuleInfo.KeyWord) ||
                                         t.Areas.Contains(YaeherModuleInfo.KeyWord) ||
                                         t.Codes.Contains(YaeherModuleInfo.KeyWord));
            }
            if (!string.IsNullOrEmpty(YaeherModuleInfo.Enabled))
            {
                YaeherModuleInfo.AndAlso(t => t.Enabled == bool.Parse(YaeherModuleInfo.Enabled));
            }
            YaeherModuleInfo.AndAlso(a => a.IsDelete == false);
            var values = await _yaeherModuleService.YaeherModuleList(YaeherModuleInfo);

            if (values.Count == 0)
            {
                this.ObjectResultModule.StatusCode = 204;
                this.ObjectResultModule.Message    = "NoContent";
                this.ObjectResultModule.Object     = "";
            }
            else
            {
                this.ObjectResultModule.Object     = values;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "YaeherModuleList",
                OperContent = JsonHelper.ToJson(YaeherModuleInfo),
                OperType    = "YaeherModuleList",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }
Exemple #7
0
        public async Task <ObjectResultModule> CreateYaeherModule([FromBody] Yaeher.YaeherAuth.Dto.YaeherModuleNode YaeherModuleInfo)
        {
            if (!Commons.CheckSecret(YaeherModuleInfo.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var            userid         = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;
            YaeherModuleIn yaeherModuleIn = new YaeherModuleIn();

            yaeherModuleIn.AndAlso(a => a.IsDelete == false);
            yaeherModuleIn.AndAlso(a => a.LinkUrls == YaeherModuleInfo.LinkUrls);
            yaeherModuleIn.AndAlso(a => a.Names == YaeherModuleInfo.Names);
            yaeherModuleIn.AndAlso(a => a.Codes == YaeherModuleInfo.Codes);
            yaeherModuleIn.AndAlso(a => a.ParentId == YaeherModuleInfo.ParentId);
            yaeherModuleIn.AndAlso(a => a.Areas == YaeherModuleInfo.Areas);
            yaeherModuleIn.AndAlso(a => a.Controllers == YaeherModuleInfo.Controllers);
            yaeherModuleIn.AndAlso(a => a.IsMenu == YaeherModuleInfo.IsMenu);
            var ModuleList = await _yaeherModuleService.YaeherModule(yaeherModuleIn);

            if (ModuleList.Count() > 0)
            {
                this.ObjectResultModule.Object     = "";
                this.ObjectResultModule.StatusCode = 100;
                this.ObjectResultModule.Message    = "菜单已存在不可新增!";
                return(ObjectResultModule);
            }
            var CreateYaeherModule = new YaeherModule()
            {
                ParentId    = YaeherModuleInfo.ParentId,
                Names       = YaeherModuleInfo.Names,
                LinkUrls    = YaeherModuleInfo.LinkUrls,
                Areas       = YaeherModuleInfo.Areas,
                Controllers = YaeherModuleInfo.Controllers,
                Actionss    = YaeherModuleInfo.Actionss,
                Icons       = YaeherModuleInfo.Icons,
                Codes       = YaeherModuleInfo.Codes,
                OrderSort   = YaeherModuleInfo.OrderSort,
                Description = YaeherModuleInfo.Description,
                IsMenu      = YaeherModuleInfo.IsMenu,
                Enabled     = YaeherModuleInfo.Enabled,
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var result = await _yaeherModuleService.CreateYaeherModule(CreateYaeherModule);

            if (result.Id > 0)
            {
                this.ObjectResultModule.Object     = result;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            else
            {
                this.ObjectResultModule.Object     = "";
                this.ObjectResultModule.StatusCode = 400;
                this.ObjectResultModule.Message    = "error!";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "CreateYaeherModule",
                OperContent = JsonHelper.ToJson(YaeherModuleInfo),
                OperType    = "CreateYaeherModule",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }
        public async Task <IList <YaeherModule> > YaeherModule(YaeherModuleIn YaeherModulefo)
        {
            var query = _repository.GetAll().Where(YaeherModulefo.Expression);

            return(await query.ToListAsync());
        }