package com.zcloud.zcGbsServicer.gatewayimpl;

import com.zcloud.zcGbsServicer.domain.gateway.RescueTeamGateway;
import com.zcloud.zcGbsServicer.domain.model.RescueTeamE;
import com.zcloud.zcGbsServicer.persistence.dataobject.RescueTeamDO;
import com.zcloud.zcGbsServicer.persistence.repository.RescueTeamRepository;
import lombok.AllArgsConstructor;
import com.zcloud.gbscommon.utils.Tools;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
* web-infrastructure
* @Author makejava
* @Date 2026-01-21 17:23:00
*/
@Service
@AllArgsConstructor
public class RescueTeamGatewayImpl implements RescueTeamGateway {
    private final RescueTeamRepository rescueTeamRepository;

    @Override
    public Boolean add(RescueTeamE rescueTeamE) {
        RescueTeamDO d = new RescueTeamDO(rescueTeamE.getTeamId());
        BeanUtils.copyProperties(rescueTeamE, d,"teamId");
        rescueTeamRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(RescueTeamE rescueTeamE) {
        RescueTeamDO d = new RescueTeamDO();
        BeanUtils.copyProperties(rescueTeamE, d);
        rescueTeamRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedRescueTeamById(Long id) {
        return rescueTeamRepository.removeById(id);
    }

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

