package org.qinan.safetyeval.infrastructure.persistence.queryservice.impl;

import com.alibaba.cola.dto.PageResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jjb.saas.framework.repository.common.PageHelper;
import lombok.AllArgsConstructor;
import org.qinan.safetyeval.client.change.request.QualFilingPersonnelChangePageQry;
import org.qinan.safetyeval.client.change.response.QualFilingPersonnelChangeCo;
import org.qinan.safetyeval.infrastructure.convertor.QualFilingPersonnelChangeDoConvertor;
import org.qinan.safetyeval.infrastructure.persistence.domainobject.QualFilingPersonnelChangeDO;
import org.qinan.safetyeval.infrastructure.persistence.queryservice.QualFilingPersonnelChangeQueryService;
import org.qinan.safetyeval.infrastructure.persistence.repository.QualFilingPersonnelChangeRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 备案申请人员-变更
 *
 * @Author: ltq
 * @date 2026-07-02 10:04:33
 */
@Service
@AllArgsConstructor
public class QualFilingPersonnelChangeQueryServiceImpl implements QualFilingPersonnelChangeQueryService {

    private final QualFilingPersonnelChangeRepository qualFilingPersonnelChangeRepository;
    private final QualFilingPersonnelChangeDoConvertor qualFilingPersonnelChangeDoConvertor;

    @Override
    public QualFilingPersonnelChangeDO getById(Long id) {
        return qualFilingPersonnelChangeRepository.getById(id);
    }

    @Override
    public PageResponse<QualFilingPersonnelChangeCo> listQualFilingPersonnelChangePage(QualFilingPersonnelChangePageQry qualFilingPersonnelChangePageQry) {
        IPage<QualFilingPersonnelChangeDO> qualFilingPersonnelChangeDoPage = qualFilingPersonnelChangeRepository.listQualFilingPersonnelChangePage(PageHelper.queryToPage(qualFilingPersonnelChangePageQry), qualFilingPersonnelChangePageQry);
        List<QualFilingPersonnelChangeCo> qualFilingPersonnelChangeCoS = qualFilingPersonnelChangeDoConvertor.converDosToCos(qualFilingPersonnelChangeDoPage.getRecords());
        return PageHelper.pageToResponse(qualFilingPersonnelChangeDoPage, qualFilingPersonnelChangeCoS);
    }

}
