コード例 #1
0
        public async Task <string> QueryPagedAsync([FromQuery] UserParam param)
        {
            var filter = param.SearchLambda <User, UserParam>();
            var result = await _userRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var userList = new List <User>();

            foreach (var item in result.Items)
            {
                var userLogins = await _userLoginRepository.QueryAsync(c => c.UserId == item.Id);

                item.LoginTimes = userLogins.Count();
                var userlogin = userLogins.OrderByDescending(c => c.CreateTime).Skip(1).FirstOrDefault();
                if (userlogin == null)
                {
                    continue;
                }
                item.LastLoginTime = userlogin.CreateTime;
                item.LastLoginIp   = userlogin.LoginIp;
            }
            var pageData = new PagedDto <User>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
コード例 #2
0
        public async Task <string> QueryPagedAsync([FromQuery] UserParam param)
        {
            var filter = param.SearchLambda <User, UserParam>();
            var result = await _userRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new LayuiTableDto <User>
            {
                Code  = "0",
                Msg   = "获取数据成功",
                Count = result.TotalResults,
                Data  = result.Items.ToList()
            };
            var json = JsonConvert.SerializeObject(pageData);

            return(json);
        }