package com.zcloud.fire.check.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.fire.check.command.convertor.FireCheckRecordHiddenCoConvertor;
import com.zcloud.fire.check.dto.FireCheckRecordHiddenPageQry;
import com.zcloud.fire.check.dto.clientobject.FireCheckRecordHiddenCO;
import com.zcloud.fire.check.persistence.dataobject.FireCheckRecordHiddenDO;
import com.zcloud.fire.check.persistence.repository.FireCheckRecordHiddenRepository;
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-12-12 11:11:15
 */
@Component
@AllArgsConstructor
public class FireCheckRecordHiddenQueryExe {
    private final FireCheckRecordHiddenRepository fireCheckRecordHiddenRepository;
    private final FireCheckRecordHiddenCoConvertor fireCheckRecordHiddenCoConvertor;

    /**
     * 分页
     *
     * @param fireCheckRecordHiddenPageQry
     * @return
     */
    public PageResponse<FireCheckRecordHiddenCO> execute(FireCheckRecordHiddenPageQry fireCheckRecordHiddenPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(fireCheckRecordHiddenPageQry);
        PageResponse<FireCheckRecordHiddenDO> pageResponse = fireCheckRecordHiddenRepository.listPage(params);
        List<FireCheckRecordHiddenCO> examCenterCOS = fireCheckRecordHiddenCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

