2019-05-01 16:46:24 +08:00
|
|
|
|
using Longbow.Web.Mvc;
|
2019-05-01 12:07:00 +08:00
|
|
|
|
using PetaPoco;
|
2019-03-04 01:27:04 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.DataAccess
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[TableName("LoginLogs")]
|
|
|
|
|
public class LoginUser
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string UserName { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTime LoginTime { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </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; }
|
|
|
|
|
|
2019-05-01 16:46:24 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
2019-04-27 20:39:24 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public string UserAgent { get; set; }
|
|
|
|
|
|
2019-03-04 01:27:04 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="user"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public virtual bool Log(LoginUser user)
|
|
|
|
|
{
|
|
|
|
|
var db = DbManager.Create();
|
|
|
|
|
db.Save(user);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-03-04 13:21:04 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2019-05-01 12:07:00 +08:00
|
|
|
|
/// <param name="po"></param>
|
2019-05-04 16:44:30 +08:00
|
|
|
|
/// <param name="ip"></param>
|
2019-03-04 13:21:04 +08:00
|
|
|
|
/// <returns></returns>
|
2019-05-04 16:44:30 +08:00
|
|
|
|
public virtual Page<LoginUser> Retrieves(PaginationOption po, string ip)
|
|
|
|
|
{
|
|
|
|
|
var sql = new Sql("select UserName, LoginTime, Ip, Browser, OS, City, Result from LoginLogs");
|
|
|
|
|
if (!string.IsNullOrEmpty(ip)) sql.Where("ip = @0", ip);
|
|
|
|
|
sql.OrderBy("LoginTime desc");
|
|
|
|
|
return DbManager.Create().Page<LoginUser>(po.PageIndex, po.Limit, sql);
|
|
|
|
|
}
|
2019-03-04 01:27:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|