package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.UserChangeRecordGateway;
import com.zcloud.basic.info.domain.model.UserChangeRecordE;
import com.zcloud.basic.info.dto.UserChangeRecordUpdateCmd;
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 14:08:19
 */
@Component
@AllArgsConstructor
public class UserChangeRecordUpdateExe {
    private final UserChangeRecordGateway userChangeRecordGateway;

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

