package com.zcloud.basic.info.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.basic.info.command.convertor.UserExpandInfoCoConvertor;
import com.zcloud.basic.info.dto.UserExpandInfoPageQry;
import com.zcloud.basic.info.dto.clientobject.UserExpandInfoCO;
import com.zcloud.basic.info.persistence.dataobject.UserExpandInfoDO;
import com.zcloud.basic.info.persistence.repository.UserExpandInfoRepository;
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 2026-01-05 14:12:19
 */
@Component
@AllArgsConstructor
public class UserExpandInfoQueryExe {
    private final UserExpandInfoRepository userExpandInfoRepository;
    private final UserExpandInfoCoConvertor userExpandInfoCoConvertor;

    /**
     * 分页
     *
     * @param userExpandInfoPageQry
     * @return
     */
    public PageResponse<UserExpandInfoCO> execute(UserExpandInfoPageQry userExpandInfoPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(userExpandInfoPageQry);
        PageResponse<UserExpandInfoDO> pageResponse = userExpandInfoRepository.listPage(params);
        List<UserExpandInfoCO> examCenterCOS = userExpandInfoCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

