package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.RzUserGateway;
import com.zcloud.basic.info.domain.model.RzUserE;
import com.zcloud.basic.info.dto.RzUserUpdateCmd;
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-02 17:15:57
 */
@Component
@AllArgsConstructor
public class RzUserUpdateExe {
    private final RzUserGateway rzUserGateway;

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

