package com.zcloud.personnel.positioning.gatewayimpl;

import com.zcloud.personnel.positioning.domain.gateway.AlarmRuleFenceRelGateway;
import com.zcloud.personnel.positioning.domain.model.AlarmRuleFenceRelE;
import com.zcloud.personnel.positioning.persistence.dataobject.AlarmRuleFenceRelDO;
import com.zcloud.personnel.positioning.persistence.repository.AlarmRuleFenceRelRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
 * web-infrastructure
 *
 * @Author fangjiakai
 * @Date 2026-07-07
 */
@Service
@AllArgsConstructor
public class AlarmRuleFenceRelGatewayImpl implements AlarmRuleFenceRelGateway {
    private final AlarmRuleFenceRelRepository alarmRuleFenceRelRepository;

    @Override
    public Boolean add(AlarmRuleFenceRelE alarmRuleFenceRelE) {
        AlarmRuleFenceRelDO dataObject = new AlarmRuleFenceRelDO();
        BeanUtils.copyProperties(alarmRuleFenceRelE, dataObject);
        alarmRuleFenceRelRepository.save(dataObject);
        return true;
    }

    @Override
    public Boolean update(AlarmRuleFenceRelE alarmRuleFenceRelE) {
        AlarmRuleFenceRelDO dataObject = new AlarmRuleFenceRelDO();
        BeanUtils.copyProperties(alarmRuleFenceRelE, dataObject);
        alarmRuleFenceRelRepository.updateById(dataObject);
        return true;
    }

    @Override
    public Boolean deletedAlarmRuleFenceRelById(Long id) {
        return alarmRuleFenceRelRepository.removeById(id);
    }

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