package com.zcloud.zcGbsServicer.command.query;

import com.zcloud.zcGbsServicer.command.convertor.ResourcePersonCoConvertor;
import com.zcloud.zcGbsServicer.dto.ResourcePersonPageQry;
import com.zcloud.zcGbsServicer.dto.clientobject.ResourcePersonCO;
import com.zcloud.zcGbsServicer.persistence.dataobject.ResourcePersonDO;
import com.zcloud.zcGbsServicer.persistence.repository.ResourcePersonRepository;
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:34
*/
@Component
@AllArgsConstructor
public class ResourcePersonQueryExe {
    private final ResourcePersonRepository resourcePersonRepository;
    private final ResourcePersonCoConvertor resourcePersonCoConvertor;

    /**
    * 分页
    *
    * @param resourcePersonPageQry
    * @return
    */
    public PageResponse<ResourcePersonCO> execute(ResourcePersonPageQry resourcePersonPageQry) {
        Map<String,Object> params = PageQueryHelper.toHashMap(resourcePersonPageQry);
        PageResponse<ResourcePersonDO> pageResponse = resourcePersonRepository.listPage(params);
            List<ResourcePersonCO> examCenterCOS = resourcePersonCoConvertor.converDOsToCOs(pageResponse.getData());
                return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

