package com.zcloud.basic.info.gatewayimpl;

import com.zcloud.basic.info.domain.gateway.RzUserGateway;
import com.zcloud.basic.info.domain.model.RzUserE;
import com.zcloud.basic.info.persistence.dataobject.RzUserDO;
import com.zcloud.basic.info.persistence.repository.RzUserRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author SondonYong
 * @Date 2025-12-02 17:15:56
 */
@Service
@AllArgsConstructor
public class RzUserGatewayImpl implements RzUserGateway {
    private final RzUserRepository rzUserRepository;

    @Override
    public Boolean add(RzUserE rzUserE) {
        RzUserDO d = new RzUserDO();
        BeanUtils.copyProperties(rzUserE, d);
        rzUserRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(RzUserE rzUserE) {
        RzUserDO d = new RzUserDO();
        BeanUtils.copyProperties(rzUserE, d);
        rzUserRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedRzUserById(Long id) {
        return rzUserRepository.removeById(id);
    }

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

