package com.zcloud.domain.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.domain.domain.gateway.ProjectTaskGroupUserGateway;
import com.zcloud.domain.domain.model.ProjectTaskGroupUserE;
import com.zcloud.domain.dto.ProjectTaskGroupUserUpdateCmd;
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-29 11:28:09
 */
@Component
@AllArgsConstructor
public class ProjectTaskGroupUserUpdateExe {
    private final ProjectTaskGroupUserGateway projectTaskGroupUserGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(ProjectTaskGroupUserUpdateCmd projectTaskGroupUserUpdateCmd) {
        ProjectTaskGroupUserE projectTaskGroupUserE = new ProjectTaskGroupUserE();
        BeanUtils.copyProperties(projectTaskGroupUserUpdateCmd, projectTaskGroupUserE);
        boolean res = projectTaskGroupUserGateway.update(projectTaskGroupUserE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

