package cn.cslg.report.service.business.InvalidReReport;

import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
import cn.cslg.report.entity.invalidReReport.AssoArguments;
import cn.cslg.report.entity.invalidReReport.AssoProofGroup;
import cn.cslg.report.mapper.InvalidReReport.AssoArgumentsMapper;
import cn.cslg.report.mapper.InvalidReReport.AssoProofGroupMapper;
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 AssoArgumentsService extends ServiceImpl<AssoArgumentsMapper, AssoArguments> {
    private final LoginUtils loginUtils;

    /**
     * 批量新增关联关系
     * @param scenarioId
     * @param argumentIds
     */
    public void add(Integer scenarioId, List<Integer> argumentIds){
        List<AssoArguments> assoArgumentsList = new ArrayList<>();
        Integer loginId = loginUtils.getId();
        if(argumentIds != null && argumentIds.size() > 0){
            for(Integer argumentId:argumentIds){
                AssoArguments assoArguments = new AssoArguments();
                assoArguments.setScenarioId(scenarioId);
                assoArguments.setArgumentId(argumentId);
                assoArguments.setCreateId(loginId);
                assoArgumentsList.add(assoArguments);
            }
            this.saveBatch(assoArgumentsList);
        }
    }
}