package com.zcloud.personnel.positioning.command;

import com.zcloud.personnel.positioning.domain.gateway.AlarmRecordTargetGateway;
import com.zcloud.personnel.positioning.domain.model.AlarmRecordTargetE;
import com.zcloud.personnel.positioning.dto.AlarmRecordTargetUpdateCmd;
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 AlarmRecordTargetUpdateExe {
    private final AlarmRecordTargetGateway alarmRecordTargetGateway;

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