package com.zcloud.zcGbsServicer.command.query;

import com.zcloud.zcGbsServicer.command.convertor.PumpRoomCoConvertor;
import com.zcloud.zcGbsServicer.dto.PumpRoomPageQry;
import com.zcloud.zcGbsServicer.dto.clientobject.PumpRoomCO;
import com.zcloud.zcGbsServicer.persistence.dataobject.PumpRoomDO;
import com.zcloud.zcGbsServicer.persistence.repository.PumpRoomRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.alibaba.cola.dto.PageResponse;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

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



/**
* web-app
* @Author makejava
* @Date 2026-01-21 17:22:16
*/
@Component
@AllArgsConstructor
public class PumpRoomQueryExe {
    private final PumpRoomRepository pumpRoomRepository;
    private final PumpRoomCoConvertor pumpRoomCoConvertor;

    /**
    * 分页
    *
    * @param pumpRoomPageQry
    * @return
    */
    public PageResponse<PumpRoomCO> execute(PumpRoomPageQry pumpRoomPageQry) {
        Map<String,Object> params = PageQueryHelper.toHashMap(pumpRoomPageQry);
        PageResponse<PumpRoomDO> pageResponse = pumpRoomRepository.listPage(params);
            List<PumpRoomCO> examCenterCOS = pumpRoomCoConvertor.converDOsToCOs(pageResponse.getData());
                return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

