package cn.cslg.report.service.business;

import cn.cslg.report.common.utils.Response;
import cn.cslg.report.entity.asso.AssoInvalidRecordFile;

import cn.cslg.report.mapper.AssoInvalidRecordFileMapper;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@Slf4j
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class AssoInvalidRecordFileService extends ServiceImpl<AssoInvalidRecordFileMapper, AssoInvalidRecordFile> {

    /**
     * @function 增加无效记录-文件关联表 对应实体：AssoInvalidRecordFile
     * @param id 无效记录id
     * @param fileIds 文件id
     * @return
     */
    public String addAsso(Integer id, List<Integer> fileIds) {
        List<AssoInvalidRecordFile> tems = new ArrayList<>();
        fileIds.forEach(item -> {
            AssoInvalidRecordFile tem = new AssoInvalidRecordFile();
            tem.setInvalidId(id);
            tem.setFileId(item);
            tems.add(tem);
        });
        this.saveBatch(tems);
        return Response.success();
    }
}
