package com.zcloud.personnel.positioning.gatewayimpl;

import com.zcloud.personnel.positioning.domain.gateway.SyncLogGateway;
import com.zcloud.personnel.positioning.domain.model.SyncLogE;
import com.zcloud.personnel.positioning.persistence.dataobject.SyncLogDO;
import com.zcloud.personnel.positioning.persistence.repository.SyncLogRepository;
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 SyncLogGatewayImpl implements SyncLogGateway {
    private final SyncLogRepository syncLogRepository;

    @Override
    public Boolean add(SyncLogE syncLogE) {
        SyncLogDO dataObject = new SyncLogDO();
        BeanUtils.copyProperties(syncLogE, dataObject);
        syncLogRepository.save(dataObject);
        return true;
    }

    @Override
    public Boolean update(SyncLogE syncLogE) {
        SyncLogDO dataObject = new SyncLogDO();
        BeanUtils.copyProperties(syncLogE, dataObject);
        syncLogRepository.updateById(dataObject);
        return true;
    }

    @Override
    public Boolean deletedSyncLogById(Long id) {
        return syncLogRepository.removeById(id);
    }

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