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

import net.northking.cctp.common.db.annotation.DatabaseWriteOnly;
import net.northking.cctp.dw.db.entity.DwAtuPlanInfo;
import net.northking.cctp.dw.db.service.DwAtuPlanInfoService;
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 = "DwAtuPlanInfoApiServiceImpl")
public class DwAtuPlanInfoApiServiceImpl implements DwAtuPlanInfoApiService{
    @Autowired
    private DwAtuPlanInfoService dwAtuPlanInfoService;
    @Override
    public Integer deleteBatch(List<Object> ids) {
        return this.dwAtuPlanInfoService.deleteByPrimaryKeys(ids);
    }

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

    @Override
    @DatabaseWriteOnly
    public String add(DwAtuPlanInfo dto)
    {
        String uuid = dto.getId();
        this.dwAtuPlanInfoService.insert(dto);
        return uuid;
    }
}
