public async Task <IActionResult> Search(string appId, SysLogType?logType, DateTime?startTime, DateTime?endTime, int current = 1, int pageSize = 20) { if (current <= 0) { throw new ArgumentException("current can not less than 1 ."); } if (pageSize <= 0) { throw new ArgumentException("pageSize can not less than 1 ."); } var pageList = await _sysLogService.SearchPage(appId, logType, startTime, endTime?.Date.AddDays(1), pageSize, current); var total = await _sysLogService.Count(appId, logType, startTime, endTime?.Date.AddDays(1)); var totalPages = total / pageSize; if ((total % pageSize) > 0) { totalPages++; } return(Json(new { current, pageSize, success = true, total = total, data = pageList })); }
public async Task <IActionResult> Search(string appId, DateTime startTime, DateTime endTime, int pageSize, int pageIndex) { if (pageSize == 0) { throw new ArgumentException("pageSize can not be 0 ."); } if (pageIndex == 0) { throw new ArgumentException("pageIndex can not be 0 ."); } var pageList = await _sysLogService.SearchPage(appId, startTime, endTime.Date.AddDays(1), pageSize, pageIndex); var total = await _sysLogService.Count(appId, startTime, endTime.Date.AddDays(1)); var totalPages = total / pageSize; if ((total % pageSize) > 0) { totalPages++; } return(Json(new { success = true, data = pageList, totalPages = totalPages })); }