package com.zcloud.domain.gatewayimpl;

import com.zcloud.domain.domain.gateway.DomainDepartmentUserGateway;
import com.zcloud.domain.domain.model.DomainDepartmentUserE;
import com.zcloud.domain.persistence.dataobject.DomainDepartmentUserDO;
import com.zcloud.domain.persistence.repository.DomainDepartmentUserRepository;
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:09
 */
@Service
@AllArgsConstructor
public class DomainDepartmentUserGatewayImpl implements DomainDepartmentUserGateway {
    private final DomainDepartmentUserRepository domainDepartmentUserRepository;

    @Override
    public Boolean add(DomainDepartmentUserE domainDepartmentUserE) {
        DomainDepartmentUserDO d = new DomainDepartmentUserDO();
        BeanUtils.copyProperties(domainDepartmentUserE, d);
        domainDepartmentUserRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(DomainDepartmentUserE domainDepartmentUserE) {
        DomainDepartmentUserDO d = new DomainDepartmentUserDO();
        BeanUtils.copyProperties(domainDepartmentUserE, d);
        domainDepartmentUserRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedDomainDepartmentUserById(Long id) {
        return domainDepartmentUserRepository.removeById(id);
    }

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

