package com.zcloud.personnel.positioning.gatewayimpl;

import com.zcloud.personnel.positioning.domain.gateway.AlarmDisposeRecordGateway;
import com.zcloud.personnel.positioning.domain.model.AlarmDisposeRecordE;
import com.zcloud.personnel.positioning.persistence.dataobject.AlarmDisposeRecordDO;
import com.zcloud.personnel.positioning.persistence.repository.AlarmDisposeRecordRepository;
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 AlarmDisposeRecordGatewayImpl implements AlarmDisposeRecordGateway {
    private final AlarmDisposeRecordRepository alarmDisposeRecordRepository;

    @Override
    public Boolean add(AlarmDisposeRecordE alarmDisposeRecordE) {
        AlarmDisposeRecordDO dataObject = new AlarmDisposeRecordDO();
        BeanUtils.copyProperties(alarmDisposeRecordE, dataObject);
        alarmDisposeRecordRepository.save(dataObject);
        return true;
    }

    @Override
    public Boolean update(AlarmDisposeRecordE alarmDisposeRecordE) {
        AlarmDisposeRecordDO dataObject = new AlarmDisposeRecordDO();
        BeanUtils.copyProperties(alarmDisposeRecordE, dataObject);
        alarmDisposeRecordRepository.updateById(dataObject);
        return true;
    }

    @Override
    public Boolean deletedAlarmDisposeRecordById(Long id) {
        return alarmDisposeRecordRepository.removeById(id);
    }

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