package com.zcloud.fire.check.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.fire.check.command.convertor.FireCheckRecordUserCoConvertor;
import com.zcloud.fire.check.dto.FireCheckRecordUserPageQry;
import com.zcloud.fire.check.dto.clientobject.FireCheckRecordUserCO;
import com.zcloud.fire.check.persistence.dataobject.FireCheckRecordUserDO;
import com.zcloud.fire.check.persistence.repository.FireCheckRecordUserRepository;
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 2025-12-12 11:12:04
 */
@Component
@AllArgsConstructor
public class FireCheckRecordUserQueryExe {
    private final FireCheckRecordUserRepository fireCheckRecordUserRepository;
    private final FireCheckRecordUserCoConvertor fireCheckRecordUserCoConvertor;

    /**
     * 分页
     *
     * @param fireCheckRecordUserPageQry
     * @return
     */
    public PageResponse<FireCheckRecordUserCO> execute(FireCheckRecordUserPageQry fireCheckRecordUserPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(fireCheckRecordUserPageQry);
        PageResponse<FireCheckRecordUserDO> pageResponse = fireCheckRecordUserRepository.listPage(params);
        List<FireCheckRecordUserCO> examCenterCOS = fireCheckRecordUserCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

