package com.zcloud.accident.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.accident.domain.gateway.AccidentGateway;
import com.zcloud.accident.domain.model.AccidentE;
import com.zcloud.accident.dto.AccidentUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;




/**
* web-app
* @Author fangjiakai
* @Date 2025-10-29 14:28:52
*/
@Component
@AllArgsConstructor
public class AccidentUpdateExe {
    private final AccidentGateway accidentGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(AccidentUpdateCmd accidentUpdateCmd) {
        AccidentE accidentE = new AccidentE();
        BeanUtils.copyProperties(accidentUpdateCmd, accidentE);
        boolean res = accidentGateway.update(accidentE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

