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.QualFilingCommitmentChangePageQry;
import org.qinan.safetyeval.client.change.response.QualFilingCommitmentChangeCo;
import org.qinan.safetyeval.infrastructure.convertor.QualFilingCommitmentChangeDoConvertor;
import org.qinan.safetyeval.infrastructure.persistence.domainobject.QualFilingCommitmentChangeDO;
import org.qinan.safetyeval.infrastructure.persistence.queryservice.QualFilingCommitmentChangeQueryService;
import org.qinan.safetyeval.infrastructure.persistence.repository.QualFilingCommitmentChangeRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 法定代人承诺书-变更
 *
 * @Author: ltq
 * @date 2026-07-02 09:38:30
 */
@Service
@AllArgsConstructor
public class QualFilingCommitmentChangeQueryServiceImpl implements QualFilingCommitmentChangeQueryService {

    private final QualFilingCommitmentChangeRepository qualFilingCommitmentChangeRepository;
    private final QualFilingCommitmentChangeDoConvertor qualFilingCommitmentChangeDoConvertor;

    @Override
    public QualFilingCommitmentChangeDO getById(Long id) {
        return qualFilingCommitmentChangeRepository.getById(id);
    }

    @Override
    public PageResponse<QualFilingCommitmentChangeCo> listQualFilingCommitmentChangePage(QualFilingCommitmentChangePageQry qualFilingCommitmentChangePageQry) {
        IPage<QualFilingCommitmentChangeDO> qualFilingCommitmentChangeDoPage = qualFilingCommitmentChangeRepository.listQualFilingCommitmentChangePage(PageHelper.queryToPage(qualFilingCommitmentChangePageQry), qualFilingCommitmentChangePageQry);
        List<QualFilingCommitmentChangeCo> qualFilingCommitmentChangeCoS = qualFilingCommitmentChangeDoConvertor.converDosToCos(qualFilingCommitmentChangeDoPage.getRecords());
        return PageHelper.pageToResponse(qualFilingCommitmentChangeDoPage, qualFilingCommitmentChangeCoS);
    }

}
