diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/LogAuditController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/LogAuditController.cs new file mode 100644 index 00000000..eaa8a0e8 --- /dev/null +++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/LogAuditController.cs @@ -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; + +/// +/// 审计日志模块 +/// +public class LogAuditController : ApiController +{ + private readonly ILogAuditService _invokeService; + + /// + /// 构造函数 + /// + /// + public LogAuditController(ILogAuditService invokeService) + { + _invokeService = invokeService; + } + + /// + /// 列表 + /// + /// + /// + [HttpPost] + [Route("GetAuditLogList")] + public DataResult> GetAuditLogList([FromBody] PageRequest request) + { + var res = _invokeService.GetAuditLogList(request); + return res; + } + + /// + /// 详情 + /// + /// + /// + [HttpGet] + [Route("GetAuditLogInfo")] + public DataResult GetAuditLogInfo([FromQuery] string id) + { + var res = _invokeService.GetAuditLogInfo(id); + return res; + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/AuditLogRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/AuditLogRes.cs new file mode 100644 index 00000000..cf9e0cbf --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Dtos/AuditLogRes.cs @@ -0,0 +1,61 @@ +using DS.Module.Core; + +namespace DS.WMS.Core.System.Dtos; + +/// +/// 审计日志返回实体 +/// +public class AuditLogRes +{ + /// + /// Id + /// + public long Id { get; set; } + /// + /// 业务id + /// + public long KeyId { get; set; } + + /// + /// sql语句 + /// + public string Sql { get; set; } + /// + /// 请求参数 + /// + public string Param { get; set; } + /// + /// 旧值 + /// + public string OldValue { get; set; } + /// + /// 新值 + /// + public string NewValue { get; set; } + /// + /// 业务数据 + /// + public string AopData { get; set; } + /// + /// 差异数据 + /// + public string DiffData { get; set; } + /// + /// 操作方式:新增、更新、删除 + /// + + public string OperateType { get; set; } + /// + /// 备注 + /// + public string Note { get; set; } = ""; + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } + /// + /// 租户id + /// + public long TenantId { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/IAdminService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/IAdminService.cs index 13539824..0915f1f3 100644 --- a/ds-wms-service/DS.WMS.Core/System/Interface/IAdminService.cs +++ b/ds-wms-service/DS.WMS.Core/System/Interface/IAdminService.cs @@ -1,4 +1,5 @@ using DS.Module.Core; +using DS.WMS.Core.System.Dtos; namespace DS.WMS.Core.System.Interface; @@ -10,4 +11,5 @@ public interface IAdminService /// DataResult GetServerInfo(); + } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/ILogAuditService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/ILogAuditService.cs new file mode 100644 index 00000000..9b5cff9b --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Interface/ILogAuditService.cs @@ -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 +{ + + /// + /// 审计日志列表 + /// + /// + /// + DataResult> GetAuditLogList(PageRequest request); + + /// + /// 审计日志详情 + /// + /// + /// + DataResult GetAuditLogInfo(string id); +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Method/AdminService.cs b/ds-wms-service/DS.WMS.Core/System/Method/AdminService.cs index af50af72..9728e8ad 100644 --- a/ds-wms-service/DS.WMS.Core/System/Method/AdminService.cs +++ b/ds-wms-service/DS.WMS.Core/System/Method/AdminService.cs @@ -1,9 +1,12 @@ using System.Diagnostics; using System.Runtime.InteropServices; using DS.Module.Core; +using DS.Module.Core.Extensions; using DS.Module.Core.Helpers; +using DS.Module.Log.Entity; using DS.Module.SqlSugar; using DS.Module.UserModule; +using DS.WMS.Core.System.Dtos; using DS.WMS.Core.System.Interface; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -77,7 +80,7 @@ public class AdminService:IAdminService }, }; return DataResult.Success(data); - } + } #endregion 获取服务器信息 } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Method/LogAuditService.cs b/ds-wms-service/DS.WMS.Core/System/Method/LogAuditService.cs new file mode 100644 index 00000000..b8599a0c --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Method/LogAuditService.cs @@ -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; + + /// + /// + /// + /// + public LogAuditService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + } + + public DataResult> GetAuditLogList(PageRequest request) + { + //序列化查询条件 + var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); + var data = db.Queryable().Filter(null,true) + .Where(whereList) + .Select().ToQueryPage(request.PageCondition); + return data; + } + + public DataResult GetAuditLogInfo(string id) + { + var data = db.Queryable().Filter(null,true) + .Where(a => a.Id == long.Parse(id)) + .Select() + .First(); + return DataResult.Success(data,MultiLanguageConst.DataQuerySuccess); + } +} \ No newline at end of file