package com.zcloud.personnel.positioning.gatewayimpl;

import com.zcloud.personnel.positioning.domain.gateway.AlarmRecordTargetGateway;
import com.zcloud.personnel.positioning.domain.model.AlarmRecordTargetE;
import com.zcloud.personnel.positioning.persistence.dataobject.AlarmRecordTargetDO;
import com.zcloud.personnel.positioning.persistence.repository.AlarmRecordTargetRepository;
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 AlarmRecordTargetGatewayImpl implements AlarmRecordTargetGateway {
    private final AlarmRecordTargetRepository alarmRecordTargetRepository;

    @Override
    public Boolean add(AlarmRecordTargetE alarmRecordTargetE) {
        AlarmRecordTargetDO dataObject = new AlarmRecordTargetDO();
        BeanUtils.copyProperties(alarmRecordTargetE, dataObject);
        alarmRecordTargetRepository.save(dataObject);
        return true;
    }

    @Override
    public Boolean update(AlarmRecordTargetE alarmRecordTargetE) {
        AlarmRecordTargetDO dataObject = new AlarmRecordTargetDO();
        BeanUtils.copyProperties(alarmRecordTargetE, dataObject);
        alarmRecordTargetRepository.updateById(dataObject);
        return true;
    }

    @Override
    public Boolean deletedAlarmRecordTargetById(Long id) {
        return alarmRecordTargetRepository.removeById(id);
    }

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