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

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.fire.check.command.convertor.FireCheckListItemCoConvertor;
import com.zcloud.fire.check.dto.FireCheckListItemPageQry;
import com.zcloud.fire.check.dto.clientobject.FireCheckListItemCO;
import com.zcloud.fire.check.persistence.dataobject.FireCheckListItemDO;
import com.zcloud.fire.check.persistence.repository.FireCheckListItemRepository;
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-11-28 10:32:28
 */
@Component
@AllArgsConstructor
public class FireCheckListItemQueryExe {
    private final FireCheckListItemRepository fireCheckListItemRepository;
    private final FireCheckListItemCoConvertor fireCheckListItemCoConvertor;

    /**
     * 分页
     *
     * @param fireCheckListItemPageQry
     * @return
     */
    public PageResponse<FireCheckListItemCO> execute(FireCheckListItemPageQry fireCheckListItemPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(fireCheckListItemPageQry);
        PageResponse<FireCheckListItemDO> pageResponse = fireCheckListItemRepository.listPage(params);
        List<FireCheckListItemCO> examCenterCOS = fireCheckListItemCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

