package com.zcloud.zcGbsServicer.gatewayimpl;

import com.zcloud.zcGbsServicer.domain.gateway.ControlRoomGateway;
import com.zcloud.zcGbsServicer.domain.model.ControlRoomE;
import com.zcloud.zcGbsServicer.persistence.dataobject.ControlRoomDO;
import com.zcloud.zcGbsServicer.persistence.repository.ControlRoomRepository;
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:21:49
*/
@Service
@AllArgsConstructor
public class ControlRoomGatewayImpl implements ControlRoomGateway {
    private final ControlRoomRepository controlRoomRepository;

    @Override
    public Boolean add(ControlRoomE controlRoomE) {
        ControlRoomDO d = new ControlRoomDO(controlRoomE.getRoomId());
        BeanUtils.copyProperties(controlRoomE, d,"roomId");
        controlRoomRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(ControlRoomE controlRoomE) {
        ControlRoomDO d = new ControlRoomDO();
        BeanUtils.copyProperties(controlRoomE, d);
        controlRoomRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedControlRoomById(Long id) {
        return controlRoomRepository.removeById(id);
    }

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

