package com.zcloud.personnel.positioning.gatewayimpl;

import com.zcloud.personnel.positioning.domain.gateway.AlarmRecordGateway;
import com.zcloud.personnel.positioning.domain.model.AlarmRecordE;
import com.zcloud.personnel.positioning.persistence.dataobject.AlarmRecordDO;
import com.zcloud.personnel.positioning.persistence.repository.AlarmRecordRepository;
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 AlarmRecordGatewayImpl implements AlarmRecordGateway {
    private final AlarmRecordRepository alarmRecordRepository;

    @Override
    public Boolean add(AlarmRecordE alarmRecordE) {
        AlarmRecordDO dataObject = new AlarmRecordDO();
        BeanUtils.copyProperties(alarmRecordE, dataObject);
        alarmRecordRepository.save(dataObject);
        return true;
    }

    @Override
    public Boolean update(AlarmRecordE alarmRecordE) {
        AlarmRecordDO dataObject = new AlarmRecordDO();
        BeanUtils.copyProperties(alarmRecordE, dataObject);
        alarmRecordRepository.updateById(dataObject);
        return true;
    }

    @Override
    public Boolean deletedAlarmRecordById(Long id) {
        return alarmRecordRepository.removeById(id);
    }

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