OperationLogCore.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc.Controllers;
  3. using Microsoft.AspNetCore.Mvc.Filters;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using dodohold.core;
  9. using Dataoke;
  10. namespace molilian.core
  11. {
  12. [Table("admin_logs")]
  13. public class OperationLog
  14. {
  15. [Key]
  16. public int Id { get; set; }
  17. public string Operator { get; set; } = string.Empty;
  18. public string OperatorIp { get; set; } = string.Empty;
  19. public string TargetObject { get; set; } = string.Empty;
  20. public string BeforeValue { get; set; } = string.Empty;
  21. public string ChangeValue { get; set; } = string.Empty;
  22. public DateTime OperationTime { get; set; } = DateTime.Now;
  23. }
  24. public partial class OperationLogCore
  25. {
  26. public static void LogOperation(string operatorName, string operatorIp, string targetObject,
  27. string beforeValue, string changeValue)
  28. {
  29. var log = new OperationLog
  30. {
  31. Operator = operatorName,
  32. OperatorIp = operatorIp,
  33. TargetObject = targetObject,
  34. BeforeValue = beforeValue,
  35. ChangeValue = changeValue,
  36. OperationTime = DateTime.Now
  37. };
  38. using var conn = DBContext.GetOpenConnection();
  39. conn.Insert(log);
  40. }
  41. }
  42. }