package com.zcloud.primeport.gatewayimpl;

import com.zcloud.primeport.domain.gateway.VehicleMessageGateway;
import com.zcloud.primeport.domain.model.VehicleMessageE;
import com.zcloud.primeport.persistence.dataobject.VehicleMessageDO;
import com.zcloud.primeport.persistence.repository.VehicleMessageRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:28
 */
@Service
@AllArgsConstructor
public class VehicleMessageGatewayImpl implements VehicleMessageGateway {
    private final VehicleMessageRepository vehicleMessageRepository;

    @Override
    public Boolean add(VehicleMessageE vehicleMessageE) {
        VehicleMessageDO d = new VehicleMessageDO();
        BeanUtils.copyProperties(vehicleMessageE, d);
        vehicleMessageRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(VehicleMessageE vehicleMessageE) {
        VehicleMessageDO d = new VehicleMessageDO();
        BeanUtils.copyProperties(vehicleMessageE, d);
        vehicleMessageRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedVehicleMessageById(Long id) {
        return vehicleMessageRepository.removeById(id);
    }

    @Override
    public Boolean deletedVehicleMessageByIds(Long[] ids) {
        return vehicleMessageRepository.removeByIds(Collections.singletonList(ids));
    }
}

