package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.UserCorpGateway;
import com.zcloud.basic.info.domain.model.UserCorpE;
import com.zcloud.basic.info.dto.UserCorpUpdateCmd;
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-02 11:13:34
 */
@Component
@AllArgsConstructor
public class UserCorpUpdateExe {
    private final UserCorpGateway userCorpGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(UserCorpUpdateCmd userCorpUpdateCmd) {
        UserCorpE userCorpE = new UserCorpE();
        BeanUtils.copyProperties(userCorpUpdateCmd, userCorpE);
        boolean res = userCorpGateway.update(userCorpE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

