package net.northking.cctp.dw.api.atu.service;

import net.northking.cctp.dw.db.entity.DwAtuPlanScriptLink;
import net.northking.cctp.dw.db.service.DwAtuPlanScriptLinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

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

@Service
@ConditionalOnMissingBean(name = "DwAtuPlanScriptLinkApiServiceImpl")
public class DwAtuPlanScriptLinkApiServiceImpl implements DwAtuPlanScriptLinkApiService {

    @Autowired
    private DwAtuPlanScriptLinkService dwAtuPlanScriptLinkService;

    @Override
    public Integer deleteBatch(List<Object> ids) {
        return this.dwAtuPlanScriptLinkService.deleteByPrimaryKeys(ids);
    }

    @Override
    public List<String> addBatch(List<DwAtuPlanScriptLink> dwAtuPlanScriptLinkList) {
        List<String> result = new ArrayList<>();
        for (DwAtuPlanScriptLink dto : dwAtuPlanScriptLinkList) {
            result.add(this.add(dto));
        }
        return result;
    }

    @Override
    public String add(DwAtuPlanScriptLink dto) {
        String uuid = dto.getId();
        this.dwAtuPlanScriptLinkService.insert(dto);
        return uuid;
    }

    @Override
    public Integer deleteByPlanIdAndScriptId(String planId, String scriptId) {
        return dwAtuPlanScriptLinkService.deleteByPlanIdAndScriptId(planId,scriptId);
    }
}
