package com.zcloud.personnel.positioning.gatewayimpl;

import com.zcloud.personnel.positioning.domain.gateway.TerminalBindGateway;
import com.zcloud.personnel.positioning.domain.model.TerminalBindE;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalBindDO;
import com.zcloud.personnel.positioning.persistence.repository.TerminalBindRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
 * web-infrastructure
 *
 * @Author fangjiakai
 * @Date 2026-07-07
 */
@Service
@AllArgsConstructor
public class TerminalBindGatewayImpl implements TerminalBindGateway {
    private final TerminalBindRepository terminalBindRepository;

    @Override
    public Boolean add(TerminalBindE terminalBindE) {
        TerminalBindDO dataObject = new TerminalBindDO();
        BeanUtils.copyProperties(terminalBindE, dataObject);
        terminalBindRepository.save(dataObject);
        return true;
    }

    @Override
    public Boolean update(TerminalBindE terminalBindE) {
        TerminalBindDO dataObject = new TerminalBindDO();
        BeanUtils.copyProperties(terminalBindE, dataObject);
        terminalBindRepository.updateById(dataObject);
        return true;
    }

    @Override
    public Boolean deletedTerminalBindById(Long id) {
        return terminalBindRepository.removeById(id);
    }

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