Esempio n. 1
0
        public async Task <PageResultModel <UserListDTO> > GetUserList(QueryUserFilterModel filterModel)
        {
            try
            {
                (List <UserListDTO> result, PageModel pageModel) = await _userService.GetUserListAsync(filterModel);

                return(PageResultModel <UserListDTO> .Success(result, pageModel, "查询成功"));
            }
            catch (AspectInvocationException ex)
            {
                return(PageResultModel <UserListDTO> .Fail(ex.InnerException?.Message));
            }
            catch (MateralConfigCenterException ex)
            {
                return(PageResultModel <UserListDTO> .Fail(ex.Message));
            }
        }
Esempio n. 2
0
        public async Task <(List <UserListDTO> result, PageModel pageModel)> GetUserListAsync(QueryUserFilterModel filterModel)
        {
            Expression <Func <User, bool> > expression = m => true;

            if (!string.IsNullOrEmpty(filterModel.Account))
            {
                expression = expression.And(m => m.Account == filterModel.Account);
            }
            if (!string.IsNullOrEmpty(filterModel.PhoneNumber))
            {
                expression = expression.And(m => EF.Functions.Like(m.PhoneNumber, $"%{filterModel.PhoneNumber}%"));
            }
            if (!string.IsNullOrEmpty(filterModel.Email))
            {
                expression = expression.And(m => EF.Functions.Like(m.Email, $"%{filterModel.Email}%"));
            }
            if (!string.IsNullOrEmpty(filterModel.Name))
            {
                expression = expression.And(m => EF.Functions.Like(m.Name, $"%{filterModel.Name}%"));
            }
            if (filterModel.Sex.HasValue)
            {
                expression = expression.And(m => m.Sex == filterModel.Sex.Value);
            }
            (List <User> usersFromDB, PageModel pageModel) = await _userRepository.PagingAsync(expression, m => m.CreateTime, SortOrder.Descending, filterModel);

            return(_mapper.Map <List <UserListDTO> >(usersFromDB), pageModel);
        }
Esempio n. 3
0
        public async Task <(List <UserListDTO> result, PageModel pageModel)> GetUserListAsync(QueryUserFilterModel filterModel)
        {
            (List <User> usersFromDB, PageModel pageModel) = await _userRepository.PagingAsync(filterModel);

            var result = _mapper.Map <List <UserListDTO> >(usersFromDB);

            return(result, pageModel);
        }
Esempio n. 4
0
        public async Task <(List <UserListDTO> result, PageModel pageModel)> GetUserListAsync(QueryUserFilterModel model)
        {
            Expression <Func <User, bool> > expression = m => true;

            if (!string.IsNullOrEmpty(model.Account))
            {
                expression = expression.And(m => m.Account == model.Account);
            }
            if (!string.IsNullOrEmpty(model.Name))
            {
                expression = expression.And(m => EF.Functions.Like(m.Name, $"%{model.Name}%"));
            }
            (List <User> userFormDB, PageModel pageModel) = await _userRepository.PagingAsync(expression, m => m.Name, model);

            var result = _mapper.Map <List <UserListDTO> >(userFormDB);

            return(result, pageModel);
        }