using Furion.JsonSerialization;
using YBEE.EQM.Core;

namespace YBEE.EQM.Application;

/// <summary>
/// 附件处理工具类
/// </summary>
public static class AttachmentUtil
{
    /// <summary>
    /// 获取附件列表
    /// </summary>
    public static List<AttachmentItem> GetList(string attachments)
    {
        return JSON.Deserialize<List<AttachmentItem>>(attachments);
    }
    /// <summary>
    /// 向附件中插入新记录
    /// </summary>
    public static string InsertInto(string attachments, AttachmentItem newItem)
    {
        var attachmentList = GetList(attachments);
        attachmentList.Add(newItem);
        return JSON.Serialize(attachmentList);
    }
}
