perf: 分页查询性能优化
This commit is contained in:
parent
db0fe72f07
commit
91c4ce98bd
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 操作日志实体类
|
||||
/// </summary>
|
||||
[TableName("Logs")]
|
||||
public class Log : Trace
|
||||
|
@ -31,7 +31,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual new Page<Log> RetrievePages(PaginationOption po, DateTime? startTime, DateTime? endTime, string opType)
|
||||
{
|
||||
var sql = new Sql("select CRUD, UserName, LogTime, Ip, Browser, OS, City, RequestUrl, RequestData from Logs");
|
||||
var sql = new Sql("select * from Logs");
|
||||
if (startTime.HasValue) sql.Where("LogTime >= @0", startTime.Value);
|
||||
if (endTime.HasValue) sql.Where("LogTime < @0", endTime.Value.AddDays(1).AddSeconds(-1));
|
||||
if (startTime == null && endTime == null) sql.Where("LogTime > @0", DateTime.Today.AddMonths(0 - DictHelper.RetrieveExceptionsLogPeriod()));
|
||||
|
@ -42,7 +42,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 查询所有操作日志
|
||||
/// </summary>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
|
|
|
@ -6,58 +6,58 @@ using System.Collections.Generic;
|
|||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 登录用户信息实体类
|
||||
/// </summary>
|
||||
[TableName("LoginLogs")]
|
||||
public class LoginUser
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 Id
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 用户名
|
||||
/// </summary>
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 登录时间
|
||||
/// </summary>
|
||||
public DateTime LoginTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 登录IP地址
|
||||
/// </summary>
|
||||
public string Ip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 登录浏览器
|
||||
/// </summary>
|
||||
public string Browser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 登录操作系统
|
||||
/// </summary>
|
||||
public string OS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 登录地点
|
||||
/// </summary>
|
||||
public string City { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 登录是否成功
|
||||
/// </summary>
|
||||
public string Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 用户 UserAgent
|
||||
/// </summary>
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 保存登录用户数据
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -69,7 +69,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得登录用户的分页数据
|
||||
/// </summary>
|
||||
/// <param name="po"></param>
|
||||
/// <param name="startTime"></param>
|
||||
|
@ -78,7 +78,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual Page<LoginUser> RetrieveByPages(PaginationOption po, DateTime? startTime, DateTime? endTime, string ip)
|
||||
{
|
||||
var sql = new Sql("select UserName, LoginTime, Ip, Browser, OS, City, Result from LoginLogs");
|
||||
var sql = new Sql("select * from LoginLogs");
|
||||
if (startTime.HasValue) sql.Where("LoginTime >= @0", startTime.Value);
|
||||
if (endTime.HasValue) sql.Where("LoginTime < @0", endTime.Value.AddDays(1));
|
||||
if (!string.IsNullOrEmpty(ip)) sql.Where("ip = @0", ip);
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 用户访问数据实体类
|
||||
/// </summary>
|
||||
[TableName("Traces")]
|
||||
public class Trace
|
||||
|
@ -32,17 +32,17 @@ namespace Bootstrap.DataAccess
|
|||
public string Ip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 客户端地点
|
||||
/// </summary>
|
||||
public string City { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 客户端浏览器
|
||||
/// </summary>
|
||||
public string Browser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 客户端操作系统
|
||||
/// </summary>
|
||||
public string OS { get; set; }
|
||||
|
||||
|
@ -52,12 +52,12 @@ namespace Bootstrap.DataAccess
|
|||
public string RequestUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得/设置 客户端 UserAgent
|
||||
/// </summary>
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保存访问历史记录
|
||||
/// 保存用户访问数据历史记录
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
public virtual bool Save(Trace p)
|
||||
|
@ -69,7 +69,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 查询用户访问分页数据
|
||||
/// </summary>
|
||||
/// <param name="po"></param>
|
||||
/// <param name="startTime"></param>
|
||||
|
@ -78,7 +78,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual Page<Trace> RetrievePages(PaginationOption po, DateTime? startTime, DateTime? endTime, string ip)
|
||||
{
|
||||
var sql = new Sql("select UserName, LogTime, IP, Browser, OS, City, RequestUrl from Traces");
|
||||
var sql = new Sql("select * from Traces");
|
||||
if (startTime.HasValue) sql.Where("LogTime > @0", startTime.Value);
|
||||
if (endTime.HasValue) sql.Where("LogTime < @0", endTime.Value.AddDays(1).AddSeconds(-1));
|
||||
if (startTime == null && endTime == null) sql.Where("LogTime > @0", DateTime.Today.AddMonths(0 - DictHelper.RetrieveAccessLogPeriod()));
|
||||
|
@ -89,7 +89,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 查询所有用户数据
|
||||
/// </summary>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
|
|
Loading…
Reference in New Issue