package com.zcloud.primeport.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.primeport.domain.gateway.VehicleViolationsGateway;
import com.zcloud.primeport.domain.model.VehicleViolationsE;
import com.zcloud.primeport.dto.VehicleViolationsUpdateCmd;
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:30
 */
@Component
@AllArgsConstructor
public class VehicleViolationsUpdateExe {
    private final VehicleViolationsGateway vehicleViolationsGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(VehicleViolationsUpdateCmd vehicleViolationsUpdateCmd) {
        VehicleViolationsE vehicleViolationsE = new VehicleViolationsE();
        BeanUtils.copyProperties(vehicleViolationsUpdateCmd, vehicleViolationsE);
        boolean res = vehicleViolationsGateway.update(vehicleViolationsE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

