package com.zcloud.zcGbsServicer.gatewayimpl;

import com.zcloud.zcGbsServicer.domain.gateway.WaterSourceGateway;
import com.zcloud.zcGbsServicer.domain.model.WaterSourceE;
import com.zcloud.zcGbsServicer.persistence.dataobject.WaterSourceDO;
import com.zcloud.zcGbsServicer.persistence.repository.WaterSourceRepository;
import lombok.AllArgsConstructor;
import com.zcloud.gbscommon.utils.Tools;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
* web-infrastructure
* @Author makejava
* @Date 2026-01-21 17:23:50
*/
@Service
@AllArgsConstructor
public class WaterSourceGatewayImpl implements WaterSourceGateway {
    private final WaterSourceRepository waterSourceRepository;

    @Override
    public Boolean add(WaterSourceE waterSourceE) {
        WaterSourceDO d = new WaterSourceDO(waterSourceE.getWaterSourceId());
        BeanUtils.copyProperties(waterSourceE, d,"waterSourceId");
        waterSourceRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(WaterSourceE waterSourceE) {
        WaterSourceDO d = new WaterSourceDO();
        BeanUtils.copyProperties(waterSourceE, d);
        waterSourceRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedWaterSourceById(Long id) {
        return waterSourceRepository.removeById(id);
    }

    @Override
    public Boolean deletedWaterSourceByIds(Long[] ids) {
        return waterSourceRepository.removeByIds(Arrays.asList(ids));
    }
}

