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

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.fire.check.command.convertor.FireCheckRecordDeviceCoConvertor;
import com.zcloud.fire.check.dto.FireCheckRecordDevicePageQry;
import com.zcloud.fire.check.dto.clientobject.FireCheckRecordDeviceCO;
import com.zcloud.fire.check.persistence.dataobject.FireCheckRecordDeviceDO;
import com.zcloud.fire.check.persistence.repository.FireCheckRecordDeviceRepository;
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:10:03
 */
@Component
@AllArgsConstructor
public class FireCheckRecordDeviceQueryExe {
    private final FireCheckRecordDeviceRepository fireCheckRecordDeviceRepository;
    private final FireCheckRecordDeviceCoConvertor fireCheckRecordDeviceCoConvertor;

    /**
     * 分页
     *
     * @param fireCheckRecordDevicePageQry
     * @return
     */
    public PageResponse<FireCheckRecordDeviceCO> execute(FireCheckRecordDevicePageQry fireCheckRecordDevicePageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(fireCheckRecordDevicePageQry);
        PageResponse<FireCheckRecordDeviceDO> pageResponse = fireCheckRecordDeviceRepository.listPage(params);
        List<FireCheckRecordDeviceCO> examCenterCOS = fireCheckRecordDeviceCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

