package com.zcloud.fire.check.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.fire.check.domain.gateway.FireCheckRecordUserGateway;
import com.zcloud.fire.check.domain.model.FireCheckRecordUserE;
import com.zcloud.fire.check.dto.FireCheckRecordUserUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author zhaokai
 * @Date 2025-12-12 11:12:05
 */
@Component
@AllArgsConstructor
public class FireCheckRecordUserUpdateExe {
    private final FireCheckRecordUserGateway fireCheckRecordUserGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(FireCheckRecordUserUpdateCmd fireCheckRecordUserUpdateCmd) {
        FireCheckRecordUserE fireCheckRecordUserE = new FireCheckRecordUserE();
        BeanUtils.copyProperties(fireCheckRecordUserUpdateCmd, fireCheckRecordUserE);
        boolean res = fireCheckRecordUserGateway.update(fireCheckRecordUserE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

