Exemplo n.º 1
0
        /// <summary>
        /// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        /// </summary>
        /// <param name="search">查询的条件</param>
        /// <returns>指定对象的集合</returns>
        public override async Task <PageResult <RoleOutputDto> > FindWithPagerAsync(SearchInputDto <Role> search)
        {
            bool order = search.Order == "asc" ? false : true;

            string where = GetDataPrivilege(false);
            if (!string.IsNullOrEmpty(search.Keywords))
            {
                where += string.Format(" and (FullName like '%{0}%' or EnCode like '%{0}%')", search.Keywords);
            }
            ;
            where += " and Category=1";
            PagerInfo pagerInfo = new PagerInfo
            {
                CurrenetPageIndex = search.CurrenetPageIndex,
                PageSize          = search.PageSize
            };
            List <Role> list = await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order);

            List <RoleOutputDto> resultList = list.MapTo <RoleOutputDto>();
            List <RoleOutputDto> listResult = new List <RoleOutputDto>();

            foreach (RoleOutputDto item in resultList)
            {
                if (!string.IsNullOrEmpty(item.OrganizeId))
                {
                    item.OrganizeName = _organizeService.Get(item.OrganizeId).FullName;
                }
                listResult.Add(item);
            }
            PageResult <RoleOutputDto> pageResult = new PageResult <RoleOutputDto>
            {
                CurrentPage  = pagerInfo.CurrenetPageIndex,
                Items        = listResult.MapTo <RoleOutputDto>(),
                ItemsPerPage = pagerInfo.PageSize,
                TotalItems   = pagerInfo.RecordCount
            };

            return(pageResult);
        }
Exemplo n.º 2
0
        public ActionResult GetForm(Guid primaryKey)
        {
            var entity = _organizeService.Get(primaryKey);

            return(Content(entity.ToJson()));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据条件查询数据库,并返回对象集合(用于分页数据显示)
        /// </summary>
        /// <param name="search">查询的条件</param>
        /// <returns>指定对象的集合</returns>
        public async Task <PageResult <UserOutputDto> > FindWithPagerSearchAsync(SearchUserModel search)
        {
            bool order = search.Order == "asc" ? false : true;

            string where = GetDataPrivilege(false);

            if (!string.IsNullOrEmpty(search.Keywords))
            {
                where += string.Format(" and (NickName like '%{0}%' or Account like '%{0}%' or RealName  like '%{0}%' or MobilePhone like '%{0}%')", search.Keywords);
            }

            if (!string.IsNullOrEmpty(search.RoleId))
            {
                where += string.Format(" and RoleId like '%{0}%'", search.RoleId);
            }
            if (!string.IsNullOrEmpty(search.CreatorTime1))
            {
                where += " and CreatorTime >='" + search.CreatorTime1 + " 00:00:00'";
            }
            if (!string.IsNullOrEmpty(search.CreatorTime2))
            {
                where += " and CreatorTime <='" + search.CreatorTime2 + " 23:59:59'";
            }
            PagerInfo pagerInfo = new PagerInfo
            {
                CurrenetPageIndex = search.CurrenetPageIndex,
                PageSize          = search.PageSize
            };
            List <User> list = await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order);

            List <UserOutputDto> resultList = list.MapTo <UserOutputDto>();
            List <UserOutputDto> listResult = new List <UserOutputDto>();

            foreach (UserOutputDto item in resultList)
            {
                if (!string.IsNullOrEmpty(item.OrganizeId))
                {
                    item.OrganizeName = _organizeService.Get(item.OrganizeId).FullName;
                }
                if (!string.IsNullOrEmpty(item.RoleId))
                {
                    item.RoleName = _roleService.GetRoleNameStr(item.RoleId);
                }
                if (!string.IsNullOrEmpty(item.DepartmentId))
                {
                    item.DepartmentName = _organizeService.Get(item.DepartmentId).FullName;
                }
                //if (!string.IsNullOrEmpty(item.DutyId))
                //{
                //    item.DutyName = _roleService.Get(item.DutyId).FullName;
                //}
                listResult.Add(item);
            }
            PageResult <UserOutputDto> pageResult = new PageResult <UserOutputDto>
            {
                CurrentPage  = pagerInfo.CurrenetPageIndex,
                Items        = listResult,
                ItemsPerPage = pagerInfo.PageSize,
                TotalItems   = pagerInfo.RecordCount
            };

            return(pageResult);
        }