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

import net.northking.cctp.dw.db.entity.DwAtuPlanBatch;
import net.northking.cctp.dw.db.service.DwAtuPlanBatchService;
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 = "DwAtuPlanBatchApiServiceImpl")
public class DwAtuPlanBatchApiServiceImpl implements DwAtuPlanBatchApiService{

    @Autowired
    private DwAtuPlanBatchService dwAtuPlanBatchService;

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

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

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