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.QualFilingEquipmentChangePageQry;
import org.qinan.safetyeval.client.change.response.QualFilingEquipmentChangeCo;
import org.qinan.safetyeval.infrastructure.convertor.QualFilingEquipmentChangeDoConvertor;
import org.qinan.safetyeval.infrastructure.persistence.domainobject.QualFilingEquipmentChangeDO;
import org.qinan.safetyeval.infrastructure.persistence.queryservice.QualFilingEquipmentChangeQueryService;
import org.qinan.safetyeval.infrastructure.persistence.repository.QualFilingEquipmentChangeRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 备案申请装备-变更
 *
 * @Author: ltq
 * @date 2026-07-02 10:03:59
 */
@Service
@AllArgsConstructor
public class QualFilingEquipmentChangeQueryServiceImpl implements QualFilingEquipmentChangeQueryService {

    private final QualFilingEquipmentChangeRepository qualFilingEquipmentChangeRepository;
    private final QualFilingEquipmentChangeDoConvertor qualFilingEquipmentChangeDoConvertor;

    @Override
    public QualFilingEquipmentChangeDO getById(Long id) {
        return qualFilingEquipmentChangeRepository.getById(id);
    }

    @Override
    public PageResponse<QualFilingEquipmentChangeCo> listQualFilingEquipmentChangePage(QualFilingEquipmentChangePageQry qualFilingEquipmentChangePageQry) {
        IPage<QualFilingEquipmentChangeDO> qualFilingEquipmentChangeDoPage = qualFilingEquipmentChangeRepository.listQualFilingEquipmentChangePage(PageHelper.queryToPage(qualFilingEquipmentChangePageQry), qualFilingEquipmentChangePageQry);
        List<QualFilingEquipmentChangeCo> qualFilingEquipmentChangeCoS = qualFilingEquipmentChangeDoConvertor.converDosToCos(qualFilingEquipmentChangeDoPage.getRecords());
        return PageHelper.pageToResponse(qualFilingEquipmentChangeDoPage, qualFilingEquipmentChangeCoS);
    }

}
