package com.zcloud.primeport.gatewayimpl;
import com.zcloud.primeport.domain.gateway.ClosedAreaCarApplyGateway;
import com.zcloud.primeport.domain.model.ClosedAreaCarApplyE;
import lombok.AllArgsConstructor;
import com.zcloud.gbscommon.utils.Tools;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.zcloud.primeport.persistence.dataobject.ClosedAreaCarApplyDO;
import com.zcloud.primeport.persistence.repository.ClosedAreaCarApplyRepository;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author dearLin
 * @Date 2026-03-20 10:07:14
 */
@Service
@AllArgsConstructor
public class ClosedAreaCarApplyGatewayImpl implements ClosedAreaCarApplyGateway {
    private final ClosedAreaCarApplyRepository closedAreaCarApplyRepository;

    @Override
    public Boolean add(ClosedAreaCarApplyE closedAreaCarApplyE) {
        ClosedAreaCarApplyDO d = new ClosedAreaCarApplyDO();
        BeanUtils.copyProperties(closedAreaCarApplyE, d);
        closedAreaCarApplyRepository.save(d);
        closedAreaCarApplyE.setId(d.getId());
        return true;
    }

    @Override
    public Boolean update(ClosedAreaCarApplyE closedAreaCarApplyE) {
        ClosedAreaCarApplyDO d = new ClosedAreaCarApplyDO();
        BeanUtils.copyProperties(closedAreaCarApplyE, d);
        closedAreaCarApplyRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedClosedAreaCarApplyById(Long id) {
        return closedAreaCarApplyRepository.removeById(id);
    }

    @Override
    public Boolean deletedClosedAreaCarApplyByIds(Long[] ids) {
        return closedAreaCarApplyRepository.removeByIds(Collections.singletonList(ids));
    }

    @Override
    public ClosedAreaCarApplyE queryById(Long id) {
        ClosedAreaCarApplyDO d = closedAreaCarApplyRepository.getById(id);
        ClosedAreaCarApplyE closedAreaCarApplyE = new ClosedAreaCarApplyE();
        BeanUtils.copyProperties(d, closedAreaCarApplyE);
        return closedAreaCarApplyE;
    }
}

