package com.zcloud.basic.info.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.basic.info.command.convertor.CorpFormCoConvertor;
import com.zcloud.basic.info.dto.CorpFormPageQry;
import com.zcloud.basic.info.dto.clientobject.CorpFormCO;
import com.zcloud.basic.info.persistence.dataobject.CorpFormDO;
import com.zcloud.basic.info.persistence.repository.CorpFormRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


/**
 * web-app
 *
 * @Author zhaokai
 * @Date 2025-10-29 16:02:27
 */
@Component
@AllArgsConstructor
public class CorpFormQueryExe {
    private final CorpFormRepository corpFormRepository;
    private final CorpFormCoConvertor corpFormCoConvertor;

    /**
     * 分页
     *
     * @param corpFormPageQry
     * @return
     */
    public PageResponse<CorpFormCO> execute(CorpFormPageQry corpFormPageQry) {
        Map<String, Object> parmas = PageQueryHelper.toHashMap(corpFormPageQry);
        PageResponse<CorpFormDO> pageResponse = corpFormRepository.listPage(parmas);
        List<CorpFormCO> examCenterCOS = corpFormCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

