BootstrapAdmin/Bootstrap.DataAccess/Helper/LogHelper.cs

36 lines
1.1 KiB
C#
Raw Normal View History

using Longbow.Cache;
using Longbow.Data;
using System;
2018-10-19 23:09:52 +08:00
using System.Collections.Generic;
using System.Linq;
2018-10-19 23:09:52 +08:00
namespace Bootstrap.DataAccess
{
/// <summary>
///
/// </summary>
2018-10-19 23:09:52 +08:00
public static class LogHelper
{
/// <summary>
///
/// </summary>
public const string RetrieveLogsDataKey = "LogHelper-RetrieveLogs";
2018-10-19 23:09:52 +08:00
/// <summary>
/// 查询所有日志信息
/// </summary>
/// <param name="tId"></param>
/// <returns></returns>
public static IEnumerable<Log> RetrieveLogs(string tId = null)
{
var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, key => DbAdapterManager.Create<Log>().RetrieveLogs(tId));
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.Id.ToString(), StringComparison.OrdinalIgnoreCase));
}
2018-10-19 23:09:52 +08:00
/// <summary>
/// 保存新增的日志信息
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public static bool SaveLog(Log p) => DbAdapterManager.Create<Log>().SaveLog(p);
}
}