package com.zcloud.zcGbsServicer.command.query;

import com.zcloud.zcGbsServicer.command.convertor.RescueTeamCoConvertor;
import com.zcloud.zcGbsServicer.dto.RescueTeamPageQry;
import com.zcloud.zcGbsServicer.dto.clientobject.RescueTeamCO;
import com.zcloud.zcGbsServicer.persistence.dataobject.RescueTeamDO;
import com.zcloud.zcGbsServicer.persistence.repository.RescueTeamRepository;
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:23:00
*/
@Component
@AllArgsConstructor
public class RescueTeamQueryExe {
    private final RescueTeamRepository rescueTeamRepository;
    private final RescueTeamCoConvertor rescueTeamCoConvertor;

    /**
    * 分页
    *
    * @param rescueTeamPageQry
    * @return
    */
    public PageResponse<RescueTeamCO> execute(RescueTeamPageQry rescueTeamPageQry) {
        Map<String,Object> params = PageQueryHelper.toHashMap(rescueTeamPageQry);
        PageResponse<RescueTeamDO> pageResponse = rescueTeamRepository.listPage(params);
            List<RescueTeamCO> examCenterCOS = rescueTeamCoConvertor.converDOsToCOs(pageResponse.getData());
                return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

