审计日志接口

master
ZR20090193-陈敬勇 9 months ago
parent fc9e652f38
commit 8d4f64dc1f

@ -0,0 +1,49 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 审计日志模块
/// </summary>
public class LogAuditController : ApiController
{
private readonly ILogAuditService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public LogAuditController(ILogAuditService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetAuditLogList")]
public DataResult<List<AuditLogRes>> GetAuditLogList([FromBody] PageRequest request)
{
var res = _invokeService.GetAuditLogList(request);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetAuditLogInfo")]
public DataResult<AuditLogRes> GetAuditLogInfo([FromQuery] string id)
{
var res = _invokeService.GetAuditLogInfo(id);
return res;
}
}

@ -0,0 +1,61 @@
using DS.Module.Core;
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 审计日志返回实体
/// </summary>
public class AuditLogRes
{
/// <summary>
/// Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 业务id
/// </summary>
public long KeyId { get; set; }
/// <summary>
/// sql语句
/// </summary>
public string Sql { get; set; }
/// <summary>
/// 请求参数
/// </summary>
public string Param { get; set; }
/// <summary>
/// 旧值
/// </summary>
public string OldValue { get; set; }
/// <summary>
/// 新值
/// </summary>
public string NewValue { get; set; }
/// <summary>
/// 业务数据
/// </summary>
public string AopData { get; set; }
/// <summary>
/// 差异数据
/// </summary>
public string DiffData { get; set; }
/// <summary>
/// 操作方式:新增、更新、删除
/// </summary>
public string OperateType { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long TenantId { get; set; }
}

@ -1,4 +1,5 @@
using DS.Module.Core; using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
namespace DS.WMS.Core.System.Interface; namespace DS.WMS.Core.System.Interface;
@ -10,4 +11,5 @@ public interface IAdminService
/// <returns></returns> /// <returns></returns>
DataResult<dynamic> GetServerInfo(); DataResult<dynamic> GetServerInfo();
} }

@ -0,0 +1,23 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface;
public interface ILogAuditService
{
/// <summary>
/// 审计日志列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<AuditLogRes>> GetAuditLogList(PageRequest request);
/// <summary>
/// 审计日志详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<AuditLogRes> GetAuditLogInfo(string id);
}

@ -1,9 +1,12 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers; using DS.Module.Core.Helpers;
using DS.Module.Log.Entity;
using DS.Module.SqlSugar; using DS.Module.SqlSugar;
using DS.Module.UserModule; using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface; using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;

@ -0,0 +1,49 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Log.Entity;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.System.Method;
public class LogAuditService : ILogAuditService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public LogAuditService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
}
public DataResult<List<AuditLogRes>> GetAuditLogList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<SysLogAudit>().Filter(null,true)
.Where(whereList)
.Select<AuditLogRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult<AuditLogRes> GetAuditLogInfo(string id)
{
var data = db.Queryable<SysLogAudit>().Filter(null,true)
.Where(a => a.Id == long.Parse(id))
.Select<AuditLogRes>()
.First();
return DataResult<AuditLogRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
}
Loading…
Cancel
Save