2018-06-07 00:45:47 +08:00
|
|
|
|
using Bootstrap.Admin.Query;
|
|
|
|
|
using Bootstrap.DataAccess;
|
|
|
|
|
using Longbow.Web.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Controllers.Api
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
public class LogsController : Controller
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public QueryData<Log> Get(QueryLogOption value)
|
|
|
|
|
{
|
|
|
|
|
return value.RetrieveData();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("{id}")]
|
|
|
|
|
public Log Get(int id)
|
|
|
|
|
{
|
|
|
|
|
return LogHelper.RetrieveLogs().FirstOrDefault(t => t.Id == id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2018-06-07 14:39:45 +08:00
|
|
|
|
public bool Post([FromBody]Log value)
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
2018-06-07 14:39:45 +08:00
|
|
|
|
value.ClientAgent = Request.Headers["User-Agent"];
|
|
|
|
|
value.ClientIp = HttpContext.Connection.RemoteIpAddress.ToString();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
value.UserName = User.Identity.Name;
|
|
|
|
|
return LogHelper.SaveLog(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-02 15:35:25 +08:00
|
|
|
|
}
|