package com.zcloud.primeport.command;

import com.zcloud.primeport.domain.gateway.VehicleDockLogGateway;
import com.zcloud.primeport.domain.model.VehicleApplyE;
import com.zcloud.primeport.domain.model.VehicleDockLogE;
import com.zcloud.primeport.dto.VehicleDockLogAddCmd;
import com.alibaba.cola.exception.BizException;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author dearLin
 * @Date 2026-04-14 14:53:29
 */
@Component
@AllArgsConstructor
public class VehicleDockLogAddExe {
    private final VehicleDockLogGateway vehicleDockLogGateway;

    @Transactional(rollbackFor = Exception.class)
    public boolean execute(VehicleDockLogAddCmd cmd) {
        VehicleDockLogE vehicleDockLogE = new VehicleDockLogE();
        BeanUtils.copyProperties(cmd, vehicleDockLogE);
        boolean res = false;
        try {
            res = vehicleDockLogGateway.add(vehicleDockLogE);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if (!res) {
            throw new BizException("保存失败");
        }
        return true;
    }


}

