| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using Yitter.IdGenerator;
- namespace Admin.NET.Plugin.AiDOP.Order;
- /// <summary>
- /// 销售订单评审业务操作日志写入(sys_log_op)
- /// </summary>
- public class SeOrderOperationLogService : ITransient
- {
- private readonly SqlSugarRepository<SysLogOp> _logOpRep;
- private readonly UserManager _userManager;
- public SeOrderOperationLogService(SqlSugarRepository<SysLogOp> logOpRep, UserManager userManager)
- {
- _logOpRep = logOpRep;
- _userManager = userManager;
- }
- /// <summary>
- /// 写入操作日志;失败不影响主流程
- /// </summary>
- public async Task WriteAsync(SeOrderOperationLogDto dto)
- {
- try
- {
- var uid = dto.UserId > 0 ? dto.UserId : _userManager.UserId;
- var requestParam = string.IsNullOrEmpty(dto.BeforeJson) && string.IsNullOrEmpty(dto.AfterJson)
- ? null
- : System.Text.Json.JsonSerializer.Serialize(new
- {
- tableName = dto.TableName,
- keyValue = dto.KeyValue,
- before = dto.BeforeJson,
- after = dto.AfterJson
- });
- await _logOpRep.InsertAsync(new SysLogOp
- {
- Id = YitIdHelper.NextId(),
- DisplayTitle = dto.Action,
- ControllerName = dto.TableName,
- ActionName = dto.Action,
- Message = dto.Content,
- RequestParam = requestParam,
- LogDateTime = DateTime.Now,
- Account = _userManager.Account,
- RealName = _userManager.RealName,
- CreateUserId = uid,
- TenantId = _userManager.TenantId,
- Status = "200",
- LogLevel = Microsoft.Extensions.Logging.LogLevel.Information,
- });
- }
- catch
- {
- // 日志失败不抛出
- }
- }
- }
|