package com.zcloud.domain.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.domain.domain.gateway.DomainDepartmentUserGateway;
import com.zcloud.domain.domain.model.DomainDepartmentUserE;
import com.zcloud.domain.dto.DomainDepartmentUserUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author zhaokai
 * @Date 2026-01-27 11:29:09
 */
@Component
@AllArgsConstructor
public class DomainDepartmentUserUpdateExe {
    private final DomainDepartmentUserGateway domainDepartmentUserGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(DomainDepartmentUserUpdateCmd domainDepartmentUserUpdateCmd) {
        DomainDepartmentUserE domainDepartmentUserE = new DomainDepartmentUserE();
        BeanUtils.copyProperties(domainDepartmentUserUpdateCmd, domainDepartmentUserE);
        boolean res = domainDepartmentUserGateway.update(domainDepartmentUserE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

