package com.zcloud.basic.info.gatewayimpl;

import com.zcloud.basic.info.domain.gateway.RzUserRecordGateway;
import com.zcloud.basic.info.domain.model.RzUserRecordE;
import com.zcloud.basic.info.persistence.dataobject.RzUserRecordDO;
import com.zcloud.basic.info.persistence.repository.RzUserRecordRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author SondonYong
 * @Date 2025-12-05 14:00:37
 */
@Service
@AllArgsConstructor
public class RzUserRecordGatewayImpl implements RzUserRecordGateway {
    private final RzUserRecordRepository rzUserRecordRepository;

    @Override
    public Boolean add(RzUserRecordE rzUserRecordE) {
        RzUserRecordDO d = new RzUserRecordDO();
        BeanUtils.copyProperties(rzUserRecordE, d);
        rzUserRecordRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(RzUserRecordE rzUserRecordE) {
        RzUserRecordDO d = new RzUserRecordDO();
        BeanUtils.copyProperties(rzUserRecordE, d);
        rzUserRecordRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedRzUserRecordById(Long id) {
        return rzUserRecordRepository.removeById(id);
    }

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

