package com.aircraft.modules.system.service.impl;

import com.aircraft.modules.system.domain.AttachmentMaterial;
import com.aircraft.modules.system.mapper.AttachmentMaterialMapper;
import com.aircraft.modules.system.service.IAttachmentMaterialService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cli
 * @since 2025-07-10
 */
@Service
public class AttachmentMaterialServiceImpl extends ServiceImpl<AttachmentMaterialMapper, AttachmentMaterial> implements IAttachmentMaterialService {

    @Override
    public void batchAddAttachmentMaterial(List<AttachmentMaterial> attachmentMaterialList) {
        this.saveBatch(attachmentMaterialList);
    }

    @Override
    public void deleteAttachmentMaterialByBusinessId(Long orderId, String code) {
        // 根据业务ID 和 code 删除记录
        this.remove(Wrappers.<AttachmentMaterial>lambdaQuery()
                .eq(AttachmentMaterial::getBusinessId, orderId)
                .eq(AttachmentMaterial::getBusinessType, code));
    }

    @Override
    public List<AttachmentMaterial> obtainAttachmentMaterialByBusinessIdAndCode(List<Long> businessIds, List<String> businessCodes) {
        return this.list(Wrappers.<AttachmentMaterial>lambdaQuery()
                .in(AttachmentMaterial::getBusinessId, businessIds)
                .in(AttachmentMaterial::getBusinessType, businessCodes));
    }
}
