package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.ImgFilesGateway;
import com.zcloud.basic.info.domain.model.ImgFilesE;
import com.zcloud.basic.info.dto.ImgFilesUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author zhangyue
 * @Date 2025-10-30 16:10:08
 */
@Component
@AllArgsConstructor
public class ImgFilesUpdateExe {
    private final ImgFilesGateway imgFilesGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(ImgFilesUpdateCmd imgFilesUpdateCmd) {
        ImgFilesE imgFilesE = new ImgFilesE();
        BeanUtils.copyProperties(imgFilesUpdateCmd, imgFilesE);
        boolean res = imgFilesGateway.update(imgFilesE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

