package org.qinan.safetyeval.infrastructure.gateway;

import lombok.AllArgsConstructor;
import org.qinan.safetyeval.domain.change.gateway.QualFilingEquipmentChangeGateway;
import org.qinan.safetyeval.domain.change.model.QualFilingEquipmentChangeE;
import org.qinan.safetyeval.infrastructure.convertor.QualFilingEquipmentChangeDoConvertor;
import org.qinan.safetyeval.infrastructure.persistence.domainobject.QualFilingEquipmentChangeDO;
import org.qinan.safetyeval.infrastructure.persistence.repository.QualFilingEquipmentChangeRepository;
import org.springframework.stereotype.Service;

/**
 * 备案申请装备-变更网关实现
 *
 * @Author: ltq
 * @date 2026-07-02 10:03:59
 */
@Service
@AllArgsConstructor
public class QualFilingEquipmentChangeGatewayImpl implements QualFilingEquipmentChangeGateway {
    private final QualFilingEquipmentChangeRepository qualFilingEquipmentChangeRepository;
    private final QualFilingEquipmentChangeDoConvertor qualFilingEquipmentChangeDoConvertor;

    @Override
    public Boolean add(QualFilingEquipmentChangeE qualFilingEquipmentChangeE) {
        QualFilingEquipmentChangeDO qualFilingEquipmentChangeDO = qualFilingEquipmentChangeDoConvertor.convertEeToDo(qualFilingEquipmentChangeE);
        boolean res = qualFilingEquipmentChangeRepository.addQualFilingEquipmentChange(qualFilingEquipmentChangeDO);
        if (res) {
            qualFilingEquipmentChangeE.setId(qualFilingEquipmentChangeDO.getId());
        }
        return res;
    }

    @Override
    public Boolean update(QualFilingEquipmentChangeE qualFilingEquipmentChangeE) {
        boolean res = qualFilingEquipmentChangeRepository.updateQualFilingEquipmentChange(qualFilingEquipmentChangeDoConvertor.convertEeToDo(qualFilingEquipmentChangeE));
        return res;
    }

    @Override
    public Boolean deletedQualFilingEquipmentChangeById(Long id) {
        return qualFilingEquipmentChangeRepository.deletedQualFilingEquipmentChangeById(id);
    }

    @Override
    public Boolean deletedQualFilingEquipmentChangeByIds(Long[] ids) {
        return qualFilingEquipmentChangeRepository.deletedQualFilingEquipmentChangeByIds(ids);
    }

    @Override
    public java.util.List<QualFilingEquipmentChangeE> listByFilingId(Long filingId) {
        return qualFilingEquipmentChangeDoConvertor.converDosToEes(
                qualFilingEquipmentChangeRepository.listByFilingId(filingId));
    }
}
