package com.zcloud.personnel.positioning.gatewayimpl;

import com.zcloud.personnel.positioning.domain.gateway.SyncTaskGateway;
import com.zcloud.personnel.positioning.domain.model.SyncTaskE;
import com.zcloud.personnel.positioning.persistence.dataobject.SyncTaskDO;
import com.zcloud.personnel.positioning.persistence.repository.SyncTaskRepository;
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 SyncTaskGatewayImpl implements SyncTaskGateway {
    private final SyncTaskRepository syncTaskRepository;

    @Override
    public Boolean add(SyncTaskE syncTaskE) {
        SyncTaskDO dataObject = new SyncTaskDO();
        BeanUtils.copyProperties(syncTaskE, dataObject);
        syncTaskRepository.save(dataObject);
        return true;
    }

    @Override
    public Boolean update(SyncTaskE syncTaskE) {
        SyncTaskDO dataObject = new SyncTaskDO();
        BeanUtils.copyProperties(syncTaskE, dataObject);
        syncTaskRepository.updateById(dataObject);
        return true;
    }

    @Override
    public Boolean deletedSyncTaskById(Long id) {
        return syncTaskRepository.removeById(id);
    }

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