Exemplo n.º 1
0
        public async Task <IPagedResult <GetTenantPageOutput> > Search(QueryTenantInput query)
        {
            var sort = new Dictionary <string, SortType>();

            if (!query.Sorting.IsNullOrEmpty())
            {
                sort.Add(query.Sorting, query.SortType);
            }
            else
            {
                sort.Add("Id", SortType.Desc);
            }

            var queryResult = await _tenantRepository.GetPageAsync(p => p.Name.Contains(query.Name), query.PageIndex,
                                                                   query.PageCount, sort);

            var output = queryResult.Item1.MapTo <IEnumerable <GetTenantPageOutput> >().GetPagedResult(queryResult.Item2);

            foreach (var item in output.Items)
            {
                await item.SetAuditInfo();
            }

            return(output);
        }
Exemplo n.º 2
0
        public async Task <Tuple <IEnumerable <Wordbook>, int> > QueryWordbooks(QueryWordbookInput query)
        {
            var queryResult = await _wordbookRepository.GetPageAsync(
                p => p.Name.Contains(query.SearchKey) || p.Code.Contains(query.SearchKey) ||
                p.Memo.Contains(query.SearchKey), query.PageIndex, query.PageCount);

            return(queryResult);
        }
Exemplo n.º 3
0
        public async Task <IPagedResult <GetUserNormOutput> > Query(QueryUserInput query)
        {
            IPagedResult <GetUserNormOutput> queryResultOutput = null;

            if (!query.OrgId.HasValue || query.OrgId == 0)
            {
                var queryPageResult = await _userRepository.GetPageAsync(p => p.UserName.Contains(query.SearchKey) ||
                                                                         p.ChineseName.Contains(query.SearchKey) ||
                                                                         p.Email.Contains(query.SearchKey) ||
                                                                         p.Phone.Contains(query.SearchKey), query.PageIndex, query.PageCount);

                queryResultOutput = queryPageResult.Item1.WhereIf(query.Status.HasValue, p => p.Status == query.Status.Value).MapTo <IEnumerable <GetUserNormOutput> >().GetPagedResult(queryPageResult.Item2);
            }
            else
            {
                var subOrgIds = await GetService <IOrganizationAppService>().GetSubOrgIds(query.OrgId.Value);

                // :todo 优化
                var queryResult = await _userRepository.GetAllAsync(p => p.UserName.Contains(query.SearchKey) ||
                                                                    p.ChineseName.Contains(query.SearchKey) ||
                                                                    p.Email.Contains(query.SearchKey) ||
                                                                    p.Phone.Contains(query.SearchKey));

                queryResult       = queryResult.Where(p => subOrgIds.Any(q => q == p.OrgId)).WhereIf(query.Status.HasValue, p => p.Status == query.Status.Value);
                queryResultOutput = queryResult.MapTo <IEnumerable <GetUserNormOutput> >().PageBy(query);
            }
            foreach (var userOutput in queryResultOutput.Items)
            {
                if (userOutput.OrgId.HasValue)
                {
                    userOutput.DeptName = (await GetService <IDepartmentAppService>().GetByOrgId(userOutput.OrgId.Value)).Name;
                }
                if (userOutput.PositionId.HasValue)
                {
                    userOutput.PositionName = (await GetService <IPositionAppService>().Get(userOutput.PositionId.Value)).Name;
                }
                userOutput.Roles = (await _userDomainService.GetUserRoles(userOutput.Id)).MapTo <IEnumerable <GetDisplayRoleOutput> >();
            }

            return(queryResultOutput);
        }
Exemplo n.º 4
0
        public async Task <IPagedResult <GetRoleOutput> > Query(QueryRoleInput query)
        {
            var queryResult = await _roleRepository.GetPageAsync(p => p.Name.Contains(query.SearchKey) && p.Memo.Contains(query.SearchKey), query.PageIndex, query.PageCount);

            var outputs = queryResult.Item1.MapTo <IEnumerable <GetRoleOutput> >().GetPagedResult(queryResult.Item2);

            foreach (var output in outputs.Items)
            {
                if (output.LastModifierUserId.HasValue)
                {
                    var modifyUserInfo = await _userInfoRepository.SingleOrDefaultAsync(p => p.Id == output.LastModifierUserId.Value);

                    if (modifyUserInfo != null)
                    {
                        output.LastModificationUserName = modifyUserInfo.ChineseName;
                    }
                }
                output.PermissionIds = (await _rolePermissionRepository.GetAllAsync(p => p.RoleId == output.Id)).Select(p => p.PermissionId).ToArray();
            }
            return(outputs);
        }
Exemplo n.º 5
0
        public async Task <IPagedResult <GetWordbookItemOutput> > GetWordbookItems(GetWordbookItemsInput input)
        {
            Wordbook wordbook = null;

            if (input.WordbookId.HasValue)
            {
                wordbook = await _wordbookRepository.SingleOrDefaultAsync(p => p.Id == input.WordbookId);

                if (wordbook == null)
                {
                    throw new BusinessException($"系统中不存在Id为{input.WordbookId}的字典类型");
                }
            }
            else
            {
                wordbook = await _wordbookRepository.SingleOrDefaultAsync(p => p.Code == input.Code);

                if (wordbook == null)
                {
                    throw new BusinessException($"系统中不存在Code为{input.Code}的字典类型");
                }
            }

            var wordbookItems = await _wordbookItemRepository.GetPageAsync(p => p.WordbookId == input.WordbookId,
                                                                           input.PageIndex, input.PageCount, new Dictionary <string, SortType> {
                { "Sort", SortType.Desc }
            });

            var wordbookItemOutputs = wordbookItems.Item1.MapTo <IEnumerable <GetWordbookItemOutput> >().Select(p =>
            {
                p.WordbookCode = wordbook.Code;
                return(p);
            }).GetPagedResult(wordbookItems.Item2);

            return(wordbookItemOutputs);
        }
Exemplo n.º 6
0
        public async Task <IPagedResult <GetRoleOutput> > Query(QueryRoleInput query)
        {
            Tuple <IEnumerable <Domain.Roles.Role>, int> queryResult = queryResult = await _roleRepository.GetPageAsync(p => p.Name.Contains(query.SearchKey) && p.Memo.Contains(query.SearchKey), query.PageIndex, query.PageCount);

            var outputs = queryResult.Item1.MapTo <IEnumerable <GetRoleOutput> >().GetPagedResult(queryResult.Item2);

            return(outputs);
        }
Exemplo n.º 7
0
        public async Task <IPagedResult <GetRoleOutput> > Query(QueryRoleInput query)
        {
            Tuple <IEnumerable <Domain.Roles.Role>, int> queryResult = queryResult = await _roleRepository.GetPageAsync(p => p.Name.Contains(query.SearchKey) && p.Memo.Contains(query.SearchKey), query.PageIndex, query.PageCount);

            var outputs = queryResult.Item1.MapTo <IEnumerable <GetRoleOutput> >().GetPagedResult(queryResult.Item2);

            foreach (var output in outputs.Items)
            {
                if (output.LastModifierUserId.HasValue)
                {
                    var modifyUserInfo = await _userRepository.SingleOrDefaultAsync(p => p.Id == output.LastModifierUserId.Value);

                    if (modifyUserInfo != null)
                    {
                        output.LastModificationUserName = modifyUserInfo.ChineseName;
                    }
                }
            }
            return(outputs);
        }