package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.RzUserRecordGateway;
import com.zcloud.basic.info.domain.model.RzUserRecordE;
import com.zcloud.basic.info.dto.RzUserRecordUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author SondonYong
 * @Date 2025-12-05 14:00:37
 */
@Component
@AllArgsConstructor
public class RzUserRecordUpdateExe {
    private final RzUserRecordGateway rzUserRecordGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(RzUserRecordUpdateCmd cmd) {
        RzUserRecordE rzUserRecordE = new RzUserRecordE();
        BeanUtils.copyProperties(cmd, rzUserRecordE);
        boolean res = rzUserRecordGateway.update(rzUserRecordE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

