package com.zcloud.zcGbsServicer.gatewayimpl;

import com.zcloud.zcGbsServicer.domain.gateway.ResourcePersonGateway;
import com.zcloud.zcGbsServicer.domain.model.ResourcePersonE;
import com.zcloud.zcGbsServicer.persistence.dataobject.ResourcePersonDO;
import com.zcloud.zcGbsServicer.persistence.repository.ResourcePersonRepository;
import lombok.AllArgsConstructor;
import com.zcloud.gbscommon.utils.Tools;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
* web-infrastructure
* @Author makejava
* @Date 2026-01-21 17:23:34
*/
@Service
@AllArgsConstructor
public class ResourcePersonGatewayImpl implements ResourcePersonGateway {
    private final ResourcePersonRepository resourcePersonRepository;

    @Override
    public Boolean add(ResourcePersonE resourcePersonE) {
        ResourcePersonDO d = new ResourcePersonDO(Tools.get32UUID());
        BeanUtils.copyProperties(resourcePersonE, d,"${uuid}");
        resourcePersonRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(ResourcePersonE resourcePersonE) {
        ResourcePersonDO d = new ResourcePersonDO();
        BeanUtils.copyProperties(resourcePersonE, d);
        resourcePersonRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedResourcePersonById(Long id) {
        return resourcePersonRepository.removeById(id);
    }

    @Override
    public Boolean deletedResourcePersonByIds(Long[] ids) {
        return resourcePersonRepository.removeByIds(Arrays.asList(ids));
    }
}

