package com.zcloud.primeport.gatewayimpl;

import com.zcloud.primeport.domain.gateway.PersonMessageGateway;
import com.zcloud.primeport.domain.model.PersonMessageE;
import com.zcloud.primeport.persistence.dataobject.PersonMessageDO;
import com.zcloud.primeport.persistence.repository.PersonMessageRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:20
 */
@Service
@AllArgsConstructor
public class PersonMessageGatewayImpl implements PersonMessageGateway {
    private final PersonMessageRepository personMessageRepository;

    @Override
    public Boolean add(PersonMessageE personMessageE) {
        PersonMessageDO d = new PersonMessageDO();
        BeanUtils.copyProperties(personMessageE, d);
        personMessageRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(PersonMessageE personMessageE) {
        PersonMessageDO d = new PersonMessageDO();
        BeanUtils.copyProperties(personMessageE, d);
        personMessageRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedPersonMessageById(Long id) {
        return personMessageRepository.removeById(id);
    }

    @Override
    public Boolean deletedPersonMessageByIds(Long[] ids) {
        return personMessageRepository.removeByIds(Collections.singletonList(ids));
    }
}

