package com.zcloud.zcGbsServicer.gatewayimpl;

import com.zcloud.zcGbsServicer.domain.gateway.PumpRoomGateway;
import com.zcloud.zcGbsServicer.domain.model.PumpRoomE;
import com.zcloud.zcGbsServicer.persistence.dataobject.PumpRoomDO;
import com.zcloud.zcGbsServicer.persistence.repository.PumpRoomRepository;
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:22:16
*/
@Service
@AllArgsConstructor
public class PumpRoomGatewayImpl implements PumpRoomGateway {
    private final PumpRoomRepository pumpRoomRepository;

    @Override
    public Boolean add(PumpRoomE pumpRoomE) {
        PumpRoomDO d = new PumpRoomDO(pumpRoomE.getPumpRoomId());
        BeanUtils.copyProperties(pumpRoomE, d,"pumpRoomId");
        pumpRoomRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(PumpRoomE pumpRoomE) {
        PumpRoomDO d = new PumpRoomDO();
        BeanUtils.copyProperties(pumpRoomE, d);
        pumpRoomRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedPumpRoomById(Long id) {
        return pumpRoomRepository.removeById(id);
    }

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

