Example #1
0
        public static PagedModel <DictDto> ToDictProfileDto(
            List <SysDict> all,
            List <SysDict> topDict,
            DictSearchDto criteria)
        {
            var model = new PagedModel <DictDto>
            {
                Ascending  = true,
                PageNumber = criteria.Page,
                PageSize   = criteria.Limit,
                Sort       = "",
                TotalCount = all.Count,
                Data       = topDict.Select(it => new DictDto
                {
                    Id         = it.Id,
                    ModifyBy   = it.ModifyBy,
                    ModifyTime = it.ModifyTime,
                    CreateBy   = it.CreateBy,
                    CreateTime = it.CreateTime,
                    Name       = it.Name,
                    Num        = it.Num,
                    Pid        = it.Pid,
                    Tips       = it.Tips
                }).ToList()
            };

            return(model);
        }
Example #2
0
        public static DictSearchDto ToDictSearchDto(DictListSearchRequest request)
        {
            var dto = new DictSearchDto
            {
                Limit = request.Limit == 0 ? 20 : request.Limit,
                Page  = request.Page == 0 ? 1 : request.Page,
                Name  = request.Name
            };

            return(dto);
        }
Example #3
0
        public async Task <PagedModel <DictDto> > GetPagedList(DictSearchDto criteria)
        {
            // 列表只显示id为0的dict,其他的是以"子节点"来显示的
            Expression <Func <SysDict, bool> > condition = it => it.Pid == 0;

            if (!string.IsNullOrWhiteSpace(criteria.Name))
            {
                condition = condition.And(it => it.Name.Contains(criteria.Name));
            }

            var all = await GetAll();

            var topDict = all
                          .Where(condition.Compile())
                          .Skip((criteria.Page - 1) * criteria.Limit)
                          .Take(criteria.Limit)
                          .ToList();

            var dto = DictMapper.ToDictProfileDto(all, topDict, criteria);

            if (dto.Count <= 0)
            {
                return(dto);
            }

            foreach (var item in dto.Data)
            {
                var sub = all.Where(it => it.Pid == item.Id).OrderBy(it => it.Num).ToList();

                if (sub.Count <= 0)
                {
                    continue;
                }

                item.Detail = string.Join(',', sub.Select(it => string.Join(':', it.Num, it.Name)).ToList());
            }

            return(dto);
        }
Example #4
0
        public async Task <List <DictDto> > GetList(DictSearchDto searchDto)
        {
            var result = new List <DictDto>();

            Expression <Func <DictDto, bool> > whereCondition = x => true;

            if (!string.IsNullOrWhiteSpace(searchDto.Name))
            {
                whereCondition = whereCondition.And(x => x.Name.Contains(searchDto.Name));
            }

            var dicts = (await this.GetAll()).OrderBy(d => d.Num).ToList();

            if (dicts.Any())
            {
                result = dicts.Where(d => d.Pid == 0).OrderBy(d => d.Num).ToList();
                foreach (var item in result)
                {
                    var subDict = dicts.Where(d => d.Pid == item.ID).OrderBy(d => d.Num).Select(d => $"{d.Num}:{d.Name}");
                    item.Detail = string.Join(";", subDict);
                }
            }
            return(result);
        }
Example #5
0
        public async Task <List <DictDto> > GetList(DictSearchDto searchDto)
        {
            List <DictDto> result = new List <DictDto>();

            Expression <Func <SysDict, bool> > whereCondition = x => true;

            if (!string.IsNullOrWhiteSpace(searchDto.Name))
            {
                whereCondition = whereCondition.And(x => x.Name.Contains(searchDto.Name));
            }

            var dicts = await _dictRepository.GetAll().Where(whereCondition).Select(d => d).OrderByDescending(d => d.CreateTime).ToListAsync();

            if (dicts.Any())
            {
                result = _mapper.Map <List <DictDto> >(dicts.Where(d => d.Pid == 0).OrderBy(d => d.Num));
                foreach (var item in result)
                {
                    var subDict = dicts.Where(d => d.Pid == item.ID).OrderBy(d => d.Num).Select(d => $"{d.Num}:{d.Name}");
                    item.Detail = string.Join(";", subDict);
                }
            }
            return(result);
        }
Example #6
0
        public async Task <AppSrvResult <List <DictDto> > > GetListAsync(DictSearchDto search)
        {
            var result = new List <DictDto>();

            Expression <Func <DictDto, bool> > whereCondition = x => true;

            if (search.Name.IsNotNullOrWhiteSpace())
            {
                whereCondition = whereCondition.And(x => x.Name.Contains(search.Name));
            }

            var dicts = (await this.GetAllFromCacheAsync()).Where(whereCondition.Compile()).OrderBy(d => d.Ordinal).ToList();

            if (dicts.Any())
            {
                result = dicts.Where(d => d.Pid == 0).OrderBy(d => d.Ordinal).ToList();
                foreach (var item in result)
                {
                    var subDicts = dicts.Where(x => x.Pid == item.Id).OrderBy(x => x.Ordinal).ToList();
                    item.Children = subDicts;
                }
            }
            return(result);
        }
Example #7
0
 public async Task <ActionResult <List <DictDto> > > GetListAsync([FromQuery] DictSearchDto search)
 {
     return(await _dictAppService.GetListAsync(search));
 }
Example #8
0
 public async Task <ActionResult <List <DictDto> > > GetDicttList([FromQuery] DictSearchDto searchDto)
 {
     return(Result(await _dictService.GetList(searchDto)));
 }