package com.zcloud.primeport.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.primeport.domain.gateway.VehicleMessageGateway;
import com.zcloud.primeport.domain.model.VehicleMessageE;
import com.zcloud.primeport.dto.VehicleMessageUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:28
 */
@Component
@AllArgsConstructor
public class VehicleMessageUpdateExe {
    private final VehicleMessageGateway vehicleMessageGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(VehicleMessageUpdateCmd vehicleMessageUpdateCmd) {
        VehicleMessageE vehicleMessageE = new VehicleMessageE();
        BeanUtils.copyProperties(vehicleMessageUpdateCmd, vehicleMessageE);
        boolean res = vehicleMessageGateway.update(vehicleMessageE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

