package org.qinan.safetyeval.infrastructure.gateway;

import lombok.AllArgsConstructor;
import org.qinan.safetyeval.domain.change.gateway.QualFilingPersonnelCertChangeGateway;
import org.qinan.safetyeval.domain.change.model.QualFilingPersonnelCertChangeE;
import org.qinan.safetyeval.infrastructure.convertor.QualFilingPersonnelCertChangeDoConvertor;
import org.qinan.safetyeval.infrastructure.persistence.domainobject.QualFilingPersonnelCertChangeDO;
import org.qinan.safetyeval.infrastructure.persistence.repository.QualFilingPersonnelCertChangeRepository;
import org.springframework.stereotype.Service;

/**
 * 备案申请人员证书网关实现
 *
 * @Author: ltq
 * @date 2026-07-02 10:04:23
 */
@Service
@AllArgsConstructor
public class QualFilingPersonnelCertChangeGatewayImpl implements QualFilingPersonnelCertChangeGateway {
    private final QualFilingPersonnelCertChangeRepository qualFilingPersonnelCertChangeRepository;
    private final QualFilingPersonnelCertChangeDoConvertor qualFilingPersonnelCertChangeDoConvertor;

    @Override
    public Boolean add(QualFilingPersonnelCertChangeE qualFilingPersonnelCertChangeE) {
        QualFilingPersonnelCertChangeDO qualFilingPersonnelCertChangeDO = qualFilingPersonnelCertChangeDoConvertor.convertEeToDo(qualFilingPersonnelCertChangeE);
        boolean res = qualFilingPersonnelCertChangeRepository.addQualFilingPersonnelCertChange(qualFilingPersonnelCertChangeDO);
        if (res) {
            qualFilingPersonnelCertChangeE.setId(qualFilingPersonnelCertChangeDO.getId());
        }
        return res;
    }

    @Override
    public Boolean update(QualFilingPersonnelCertChangeE qualFilingPersonnelCertChangeE) {
        boolean res = qualFilingPersonnelCertChangeRepository.updateQualFilingPersonnelCertChange(qualFilingPersonnelCertChangeDoConvertor.convertEeToDo(qualFilingPersonnelCertChangeE));
        return res;
    }

    @Override
    public Boolean deletedQualFilingPersonnelCertChangeById(Long id) {
        return qualFilingPersonnelCertChangeRepository.deletedQualFilingPersonnelCertChangeById(id);
    }

    @Override
    public Boolean deletedQualFilingPersonnelCertChangeByIds(Long[] ids) {
        return qualFilingPersonnelCertChangeRepository.deletedQualFilingPersonnelCertChangeByIds(ids);
    }

    @Override
    public java.util.List<QualFilingPersonnelCertChangeE> listByFilingId(Long filingId) {
        return qualFilingPersonnelCertChangeDoConvertor.converDosToEes(
                qualFilingPersonnelCertChangeRepository.listByFilingId(filingId));
    }
}
