コード例 #1
0
ファイル: AreaController.cs プロジェクト: EricLisi/WMSProduct
        public async Task <IActionResult> GetAllArea([FromQuery] ModuleIndexCondition condition)
        {
            //设置分页对象
            var pager = SetPager(1, 99999, "EnCode", "ASC");
            //设置过滤条件
            var condList = new List <SearchCondition>();

            if (!string.IsNullOrEmpty(condition.EnCode))
            {
                condList.Add(new SearchCondition
                {
                    Filed     = "EnCode",
                    Value     = condition.EnCode,
                    Operation = CommonEnum.ConditionOperation.Like
                });
            }
            if (!string.IsNullOrEmpty(condition.FullName))
            {
                condList.Add(new SearchCondition
                {
                    Filed     = "FullName",
                    Value     = condition.FullName,
                    Operation = CommonEnum.ConditionOperation.Like
                });
            }

            //数据库查询
            var list = await _service.QueryAreaByPagesAsync(pager, condList);

            if (list == null || list.Entity == null || list.Entity.Count() == 0)
            {
                return(NotFound());
            }
            //返回分页结果
            return(PagerListAction(pager, list));
            //var entity = await _service.QueryAll();
            //if (entity == null)
            //{
            //    return NotFound();
            //}
            //return Ok(entity);
        }
コード例 #2
0
        public async Task <IActionResult> GetModuleByPagesAsync([FromQuery] ModuleIndexCondition condition)
        {
            //设置分页对象
            var pager = SetPager(condition.Page, condition.Rows, condition.SIdx, condition.Sord);
            //设置过滤条件
            var condList = new List <SearchCondition>();

            if (!string.IsNullOrEmpty(condition.EnCode))
            {
                condList.Add(new SearchCondition
                {
                    Filed     = "EnCode",
                    Value     = condition.EnCode,
                    Operation = CommonEnum.ConditionOperation.Like
                });
            }
            if (!string.IsNullOrEmpty(condition.FullName))
            {
                condList.Add(new SearchCondition
                {
                    Filed     = "FullName",
                    Value     = condition.FullName,
                    Operation = CommonEnum.ConditionOperation.Like
                });
            }

            if (!string.IsNullOrEmpty(condition.ModuleId))
            {
                condList.Add(new SearchCondition
                {
                    Filed     = "ParentId",
                    Value     = condition.ModuleId,
                    Operation = CommonEnum.ConditionOperation.Equal
                });
            }
            //数据库查询
            var entity = await _service.QueryModuleByPagesAsync(pager, condList);

            //返回分页结果
            return(PagerListAction(pager, entity));
        }