package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.UserJobHandoverGateway;
import com.zcloud.basic.info.domain.model.UserJobHandoverE;
import com.zcloud.basic.info.dto.UserJobHandoverUpdateCmd;
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:57
 */
@Component
@AllArgsConstructor
public class UserJobHandoverUpdateExe {
    private final UserJobHandoverGateway userJobHandoverGateway;

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

