package com.zcloud.domain.gatewayimpl;

import com.zcloud.domain.domain.gateway.DomainGroupUserGateway;
import com.zcloud.domain.domain.model.DomainGroupUserE;
import com.zcloud.domain.persistence.dataobject.DomainGroupUserDO;
import com.zcloud.domain.persistence.repository.DomainGroupUserRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author zhaokai
 * @Date 2026-01-27 11:29:42
 */
@Service
@AllArgsConstructor
public class DomainGroupUserGatewayImpl implements DomainGroupUserGateway {
    private final DomainGroupUserRepository domainGroupUserRepository;

    @Override
    public Boolean add(DomainGroupUserE domainGroupUserE) {
        DomainGroupUserDO d = new DomainGroupUserDO();
        BeanUtils.copyProperties(domainGroupUserE, d);
        domainGroupUserRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(DomainGroupUserE domainGroupUserE) {
        DomainGroupUserDO d = new DomainGroupUserDO();
        BeanUtils.copyProperties(domainGroupUserE, d);
        domainGroupUserRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedDomainGroupUserById(Long id) {
        return domainGroupUserRepository.removeById(id);
    }

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

