AuditUtil.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Furion.JsonSerialization;
  2. using YBEE.EQM.Core;
  3. namespace YBEE.EQM.Application;
  4. /// <summary>
  5. /// 审核记录工具类
  6. /// </summary>
  7. public static class AuditUtil
  8. {
  9. /// <summary>
  10. /// 创建一个新的审核记录
  11. /// </summary>
  12. /// <param name="actionType"></param>
  13. /// <param name="status"></param>
  14. /// <param name="createTime"></param>
  15. /// <param name="remark"></param>
  16. /// <returns></returns>
  17. public static AuditItem CreateNew(AuditActionType actionType, AuditStatus status, DateTime? createTime = null, string remark = "")
  18. {
  19. return new()
  20. {
  21. SysOrgId = CurrentSysUserInfo.SysOrgId,
  22. SysOrgName = CurrentSysUserInfo.SysOrgName,
  23. SysUserId = CurrentSysUserInfo.SysUserId,
  24. SysUserName = CurrentSysUserInfo.Name,
  25. Remark = remark,
  26. CreateTime = createTime ?? DateTime.Now,
  27. Status = status,
  28. ActionType = actionType,
  29. };
  30. }
  31. /// <summary>
  32. /// 获取审核记录列表
  33. /// </summary>
  34. public static List<AuditItem> GetList(string audits)
  35. {
  36. return JSON.Deserialize<List<AuditItem>>(audits);
  37. }
  38. /// <summary>
  39. /// 向审核记录中插入新记录
  40. /// </summary>
  41. public static string InsertInto(string audits, AuditItem newItem)
  42. {
  43. var auditList = GetList(audits);
  44. newItem.Id = (auditList.Count > 0 ? auditList.Max(a => a.Id) : 0) + 1;
  45. auditList.Add(newItem);
  46. return JSON.Serialize(auditList);
  47. }
  48. }