package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.DepartmentSuperviseGateway;
import com.zcloud.basic.info.domain.model.DepartmentSuperviseE;
import com.zcloud.basic.info.dto.DepartmentSuperviseUpdateCmd;
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-11-10 14:13:46
 */
@Component
@AllArgsConstructor
public class DepartmentSuperviseUpdateExe {
    private final DepartmentSuperviseGateway departmentSuperviseGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(DepartmentSuperviseUpdateCmd departmentSuperviseUpdateCmd) {
        DepartmentSuperviseE departmentSuperviseE = new DepartmentSuperviseE();
        BeanUtils.copyProperties(departmentSuperviseUpdateCmd, departmentSuperviseE);
        boolean res = departmentSuperviseGateway.update(departmentSuperviseE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

