package com.zcloud.personnel.positioning.gatewayimpl;

import com.zcloud.personnel.positioning.domain.gateway.FencePointGateway;
import com.zcloud.personnel.positioning.domain.model.FencePointE;
import com.zcloud.personnel.positioning.persistence.dataobject.FencePointDO;
import com.zcloud.personnel.positioning.persistence.repository.FencePointRepository;
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 FencePointGatewayImpl implements FencePointGateway {
    private final FencePointRepository fencePointRepository;

    @Override
    public Boolean add(FencePointE fencePointE) {
        FencePointDO dataObject = new FencePointDO();
        BeanUtils.copyProperties(fencePointE, dataObject);
        fencePointRepository.save(dataObject);
        return true;
    }

    @Override
    public Boolean update(FencePointE fencePointE) {
        FencePointDO dataObject = new FencePointDO();
        BeanUtils.copyProperties(fencePointE, dataObject);
        fencePointRepository.updateById(dataObject);
        return true;
    }

    @Override
    public Boolean deletedFencePointById(Long id) {
        return fencePointRepository.removeById(id);
    }

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