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.QualFilingMaterialChangePageQry;
import org.qinan.safetyeval.client.change.response.QualFilingMaterialChangeCo;
import org.qinan.safetyeval.infrastructure.convertor.QualFilingMaterialChangeDoConvertor;
import org.qinan.safetyeval.infrastructure.persistence.domainobject.QualFilingMaterialChangeDO;
import org.qinan.safetyeval.infrastructure.persistence.queryservice.QualFilingMaterialChangeQueryService;
import org.qinan.safetyeval.infrastructure.persistence.repository.QualFilingMaterialChangeRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 备案申请材料-变更
 *
 * @Author: ltq
 * @date 2026-07-02 10:04:07
 */
@Service
@AllArgsConstructor
public class QualFilingMaterialChangeQueryServiceImpl implements QualFilingMaterialChangeQueryService {

    private final QualFilingMaterialChangeRepository qualFilingMaterialChangeRepository;
    private final QualFilingMaterialChangeDoConvertor qualFilingMaterialChangeDoConvertor;

    @Override
    public QualFilingMaterialChangeDO getById(Long id) {
        return qualFilingMaterialChangeRepository.getById(id);
    }

    @Override
    public PageResponse<QualFilingMaterialChangeCo> listQualFilingMaterialChangePage(QualFilingMaterialChangePageQry qualFilingMaterialChangePageQry) {
        IPage<QualFilingMaterialChangeDO> qualFilingMaterialChangeDoPage = qualFilingMaterialChangeRepository.listQualFilingMaterialChangePage(PageHelper.queryToPage(qualFilingMaterialChangePageQry), qualFilingMaterialChangePageQry);
        List<QualFilingMaterialChangeCo> qualFilingMaterialChangeCoS = qualFilingMaterialChangeDoConvertor.converDosToCos(qualFilingMaterialChangeDoPage.getRecords());
        return PageHelper.pageToResponse(qualFilingMaterialChangeDoPage, qualFilingMaterialChangeCoS);
    }

}
