package com.ruoyi.project.business.service.system;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.project.business.domain.system.SysAttachment;
import com.ruoyi.project.business.domain.system.SysAttachmentHistory;
import com.ruoyi.project.business.dto.SysAttachmentDto;
import com.ruoyi.project.business.enums.CategoryEnum;
import com.ruoyi.project.business.enums.FunctionEnum;
import com.ruoyi.project.business.enums.ModuleEnum;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 附件表 服务类
 * </p>
 *
 * @author CAC
 * @since 2023-09-28
 */
public interface ISysAttachmentService extends IService<SysAttachment> {

    /**
     * 更新单条数据的附件
     *
     * @param id          需要更新附件的数据id
     * @param module
     * @param category
     * @param attachments
     */
    void updateAttachments(Integer id, ModuleEnum module, FunctionEnum func, CategoryEnum category, List<SysAttachment> attachments);

    /**
     * 批量更新多条数据的附件
     *
     * @param ids         需要删除附件的数据ids
     * @param module
     * @param category
     * @param attachments 需要插入的附件列表
     */
    void updateAttachmentsBatch(List<Integer> ids, ModuleEnum module, FunctionEnum func, CategoryEnum category, List<SysAttachment> attachments);

    /**
     * 获取单条数据的附件
     *
     * @param id
     * @param module
     * @param category
     * @return
     */
    List<SysAttachment> getAttachments(Integer id, ModuleEnum module, FunctionEnum func, CategoryEnum category);

    List<SysAttachmentHistory> getHistoryAttachments(Integer id, ModuleEnum module, FunctionEnum func, CategoryEnum category);

    /**
     * 批量获取多条数据的附件
     *
     * @param ids
     * @param module
     * @param category
     * @return
     */
    Map<Integer, List<SysAttachment>> getAttachmentsMap(List<Integer> ids, ModuleEnum module, FunctionEnum func, CategoryEnum category);


    /**
     * 保存数据附件履历
     *
     * @param idMap    key为原businessId value为historyId
     * @param module
     * @param category
     */
    void saveHistory(Map<Integer, Integer> idMap, ModuleEnum module, FunctionEnum func, CategoryEnum category);

    void saveAttachment(Integer businessId, String path, ModuleEnum moduleEnum, FunctionEnum functionEnum, CategoryEnum categoryEnum);

    int attachmentsBatchUpdate(SysAttachmentDto dto);

}
