package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.UserCorpRecordGateway;
import com.zcloud.basic.info.domain.model.UserCorpRecordE;
import com.zcloud.basic.info.dto.UserCorpRecordUpdateCmd;
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-03 10:21:59
 */
@Component
@AllArgsConstructor
public class UserCorpRecordUpdateExe {
    private final UserCorpRecordGateway userCorpRecordGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(UserCorpRecordUpdateCmd userCorpRecordUpdateCmd) {
        UserCorpRecordE userCorpRecordE = new UserCorpRecordE();
        BeanUtils.copyProperties(userCorpRecordUpdateCmd, userCorpRecordE);
        boolean res = userCorpRecordGateway.update(userCorpRecordE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

