package com.zcloud.zcGbsServicer.command.query;

import com.zcloud.zcGbsServicer.command.convertor.ControlRoomCoConvertor;
import com.zcloud.zcGbsServicer.dto.ControlRoomPageQry;
import com.zcloud.zcGbsServicer.dto.clientobject.ControlRoomCO;
import com.zcloud.zcGbsServicer.persistence.dataobject.ControlRoomDO;
import com.zcloud.zcGbsServicer.persistence.repository.ControlRoomRepository;
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:21:50
*/
@Component
@AllArgsConstructor
public class ControlRoomQueryExe {
    private final ControlRoomRepository controlRoomRepository;
    private final ControlRoomCoConvertor controlRoomCoConvertor;

    /**
    * 分页
    *
    * @param controlRoomPageQry
    * @return
    */
    public PageResponse<ControlRoomCO> execute(ControlRoomPageQry controlRoomPageQry) {
        Map<String,Object> params = PageQueryHelper.toHashMap(controlRoomPageQry);
        PageResponse<ControlRoomDO> pageResponse = controlRoomRepository.listPage(params);
            List<ControlRoomCO> examCenterCOS = controlRoomCoConvertor.converDOsToCOs(pageResponse.getData());
                return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

