public async Task<List<LogApiEntity>> GetPageList(LogApiListParam param, Pagination pagination) { var strSql = new StringBuilder(); List<DbParameter> filter = ListFilter(param, strSql); var list = await this.BaseRepository().FindList<LogApiEntity>(strSql.ToString(), filter.ToArray(), pagination); return list.ToList(); }
public async Task <TData <List <LogApiEntity> > > GetPageListJson([FromQuery] LogApiListParam param, [FromQuery] Pagination pagination) { var obj = await _logApiBLL.GetPageList(param, pagination); return(obj); }
public async Task <TData <List <LogApiEntity> > > GetPageList(LogApiListParam param, Pagination pagination) { TData <List <LogApiEntity> > obj = new TData <List <LogApiEntity> >(); obj.Data = await logApiService.GetPageList(param, pagination); obj.Total = pagination.TotalCount; obj.Tag = 1; return(obj); }
public async Task <TData <List <LogApiEntity> > > GetList(LogApiListParam param) { TData <List <LogApiEntity> > obj = new TData <List <LogApiEntity> >(); obj.Data = await logApiService.GetList(param); obj.Total = obj.Data.Count; obj.Tag = 1; return(obj); }
public async Task <TData <List <LogApiEntity> > > GetList(LogApiListParam param) { var obj = new TData <List <LogApiEntity> >(); obj.Data = await _logApiService.GetList(param); obj.Data.ForEach(a => a.IpLocation = IpLocationHelper.GetIpLocation(a.IpAddress)); obj.Tag = 1; return(obj); }
private List <DbParameter> ListFilter(LogApiListParam param, StringBuilder strSql) { strSql.Append(@"SELECT a.Id, a.BaseCreateTime, a.BaseCreatorId, a.LogStatus, a.Remark, a.ExecuteUrl, a.ExecuteParam, a.ExecuteResult, a.ExecuteTime, b.UserName, c.DepartmentName FROM SysLogApi a LEFT JOIN SysUser b ON a.BaseCreatorId = b.Id LEFT JOIN SysDepartment c ON b.DepartmentId = c.Id WHERE 1 = 1"); var parameter = new List <DbParameter>(); if (param != null) { if (!string.IsNullOrEmpty(param.UserName)) { strSql.Append(" AND b.UserName like @UserName"); parameter.Add(DbParameterExtension.CreateDbParameter("@UserName", '%' + param.UserName + '%')); } if (param.LogStatus > -1) { strSql.Append(" AND a.LogStatus = @LogStatus"); parameter.Add(DbParameterExtension.CreateDbParameter("@LogStatus", param.LogStatus)); } if (!string.IsNullOrEmpty(param.ExecuteUrl)) { strSql.Append(" AND a.ExecuteUrl like @ExecuteUrl"); parameter.Add(DbParameterExtension.CreateDbParameter("@ExecuteUrl", '%' + param.ExecuteUrl + '%')); } if (!string.IsNullOrEmpty(param.StartTime.ParseToString())) { strSql.Append(" AND a.BaseCreateTime >= @StartTime"); parameter.Add(DbParameterExtension.CreateDbParameter("@StartTime", param.StartTime)); } if (!string.IsNullOrEmpty(param.EndTime.ParseToString())) { param.EndTime = (param.EndTime.Value.ToString("yyyy-MM-dd") + " 23:59:59").ParseToDateTime(); strSql.Append(" AND a.BaseCreateTime <= @EndTime"); parameter.Add(DbParameterExtension.CreateDbParameter("@EndTime", param.EndTime)); } } return(parameter); }
private List <DbParameter> ListFilter(LogApiListParam param, StringBuilder strSql) { strSql.Append(@"SELECT a.id as Id, a.base_create_time as BaseCreateTime, a.base_creator_id as BaseCreatorId, a.log_status as LogStatus, a.remark as Remark, a.execute_url as ExecuteUrl, a.execute_param as ExecuteParam, a.execute_result as ExecuteResult, a.execute_time as ExecuteTime, b.user_name as UserName, c.department_name as DepartmentName FROM sys_log_api a LEFT JOIN sys_user b ON a.base_creator_id = b.id LEFT JOIN sys_department c ON b.department_id = c.id WHERE 1 = 1"); var parameter = new List <DbParameter>(); if (param != null) { if (!string.IsNullOrEmpty(param.UserName)) { strSql.Append(" AND b.user_name like @UserName"); parameter.Add(DbParameterExtension.CreateDbParameter("@UserName", '%' + param.UserName + '%')); } if (param.LogStatus > -1) { strSql.Append(" AND a.log_status = @LogStatus"); parameter.Add(DbParameterExtension.CreateDbParameter("@LogStatus", param.LogStatus)); } if (!string.IsNullOrEmpty(param.ExecuteUrl)) { strSql.Append(" AND a.execute_url like @ExecuteUrl"); parameter.Add(DbParameterExtension.CreateDbParameter("@ExecuteUrl", '%' + param.ExecuteUrl + '%')); } if (!string.IsNullOrEmpty(param.StartTime.ParseToString())) { strSql.Append(" AND a.base_create_time >= @StartTime"); parameter.Add(DbParameterExtension.CreateDbParameter("@StartTime", param.StartTime)); } if (!string.IsNullOrEmpty(param.EndTime.ParseToString())) { param.EndTime = (param.EndTime.Value.ToString("yyyy-MM-dd") + " 23:59:59").ParseToDateTime(); strSql.Append(" AND a.base_create_time <= @EndTime"); parameter.Add(DbParameterExtension.CreateDbParameter("@EndTime", param.EndTime)); } } return(parameter); }
/// <summary> /// 分页查询 /// </summary> public async Task <List <LogApiEntity> > GetPageList(LogApiListParam param, Pagination pagination) { #region 查询条件 var query = ListFilter(param); var data = await query.OrderByDescending(a => a.Id) .ToPagedListAsync(pagination.PageIndex, pagination.PageSize); #endregion // 分页参数赋值 pagination.TotalCount = data.TotalCount; return(data.Items.ToList()); }
private IQueryable <LogApiEntity> ListFilter(LogApiListParam param) { var query = from a in _logApiEntityDB.AsQueryable() join b in _userEntityDB.AsQueryable() on a.CreatorId equals b.Id into ab from res in ab.DefaultIfEmpty() select new LogApiEntity { Id = a.Id, Remark = a.Remark, UserName = res.UserName, ExecuteParam = a.ExecuteParam, ExecuteResult = a.ExecuteResult, ExecuteTime = a.ExecuteTime, ExecuteUrl = a.ExecuteUrl, LogStatus = a.LogStatus, IpAddress = a.IpAddress, IpLocation = IpLocationHelper.GetIpLocation(a.IpAddress), CreateTime = a.CreateTime }; if (!string.IsNullOrEmpty(param.UserName)) { query = query.Where(p => p.UserName.Contains(param.UserName)); } if (param.LogStatus > -1) { query = query.Where(p => p.LogStatus == param.LogStatus); } if (!string.IsNullOrEmpty(param.IpAddress)) { query = query.Where(p => p.IpAddress.Contains(param.IpAddress)); } if (param.StartTime.HasValue) { query = query.Where(p => p.CreateTime >= param.StartTime); } if (param.EndTime.HasValue) { query = query.Where(p => p.CreateTime <= param.EndTime.Value.AddDays(1)); } return(query); }
/// <summary> /// 带条件查询所有 /// </summary> public async Task <List <LogApiEntity> > GetList(LogApiListParam param) { #region 查询条件 var query = _logApiEntityDB.AsQueryable(); /* * // 执行状态(0失败 1成功) * if (param.LogStatus.HasValue) * query = query.Where(p => p.LogStatus == param.LogStatus); * // 接口地址 * if (!string.IsNullOrEmpty(param.ExecuteUrl)) * query = query.Where(p => p.ExecuteUrl.Contains(param.ExecuteUrl)); * */ #endregion var data = await query.ToListAsync(); return(data); }
public async Task <IActionResult> GetPageListJson(LogApiListParam param, Pagination pagination) { TData <List <LogApiEntity> > obj = await logApiBLL.GetPageList(param, pagination); return(Json(obj)); }
public async Task <TData <List <LogApiEntity> > > GetListJson([FromQuery] LogApiListParam param) { var obj = await _logApiBLL.GetList(param); return(obj); }