package com.zcloud.primeport.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.primeport.domain.gateway.PersonMessageGateway;
import com.zcloud.primeport.domain.model.PersonMessageE;
import com.zcloud.primeport.dto.PersonMessageUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:21
 */
@Component
@AllArgsConstructor
public class PersonMessageUpdateExe {
    private final PersonMessageGateway personMessageGateway;

    @Transactional(rollbackFor = Exception.class)
    public void execute(PersonMessageUpdateCmd personMessageUpdateCmd) {
        PersonMessageE personMessageE = new PersonMessageE();
        BeanUtils.copyProperties(personMessageUpdateCmd, personMessageE);
        boolean res = personMessageGateway.update(personMessageE);
        if (!res) {
            throw new BizException("修改失败");
        }
    }
}

