package com.zcloud.primeport.gatewayimpl;

import com.zcloud.primeport.domain.gateway.ClosedAreaPersonApplyGateway;
import com.zcloud.primeport.domain.model.ClosedAreaPersonApplyE;
import com.zcloud.primeport.persistence.dataobject.ClosedAreaPersonApplyDO;
import com.zcloud.primeport.persistence.repository.ClosedAreaPersonApplyRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
* web-infrastructure
* @Author dearLin
* @Date 2026-03-19 13:59:16
*/
@Service
@AllArgsConstructor
public class ClosedAreaPersonApplyGatewayImpl implements ClosedAreaPersonApplyGateway {
    private final ClosedAreaPersonApplyRepository closedAreaPersonApplyRepository;

    @Override
    public Boolean add(ClosedAreaPersonApplyE closedAreaPersonApplyE) {
        ClosedAreaPersonApplyDO d = new ClosedAreaPersonApplyDO();
        BeanUtils.copyProperties(closedAreaPersonApplyE, d);
        closedAreaPersonApplyRepository.save(d);
        closedAreaPersonApplyE.setId(d.getId());
        return true;
    }

    @Override
    public Boolean update(ClosedAreaPersonApplyE closedAreaPersonApplyE) {
        ClosedAreaPersonApplyDO d = new ClosedAreaPersonApplyDO();
        BeanUtils.copyProperties(closedAreaPersonApplyE, d);
        closedAreaPersonApplyRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedClosedAreaPersonApplyById(Long id) {
        return closedAreaPersonApplyRepository.removeById(id);
    }

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

    @Override
    public ClosedAreaPersonApplyE queryById(Long id) {
        ClosedAreaPersonApplyDO d = closedAreaPersonApplyRepository.getById(id);
        ClosedAreaPersonApplyE e = new ClosedAreaPersonApplyE();
        BeanUtils.copyProperties(d, e);
        return e;
    }


}

