package com.zcloud.personnel.positioning.command;

import com.zcloud.personnel.positioning.domain.gateway.SyncLogGateway;
import com.zcloud.personnel.positioning.domain.model.SyncLogE;
import com.zcloud.personnel.positioning.dto.SyncLogUpdateCmd;
import com.alibaba.cola.exception.BizException;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * web-app
 *
 * @Author fangjiakai
 * @Date 2026-07-07
 */
@Component
@AllArgsConstructor
public class SyncLogUpdateExe {
    private final SyncLogGateway syncLogGateway;

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