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

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.fire.check.command.convertor.FireCheckListUserCoConvertor;
import com.zcloud.fire.check.dto.FireCheckListUserPageQry;
import com.zcloud.fire.check.dto.clientobject.FireCheckListUserCO;
import com.zcloud.fire.check.persistence.dataobject.FireCheckListUserDO;
import com.zcloud.fire.check.persistence.repository.FireCheckListUserRepository;
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-11 15:32:50
 */
@Component
@AllArgsConstructor
public class FireCheckListUserQueryExe {
    private final FireCheckListUserRepository fireCheckListUserRepository;
    private final FireCheckListUserCoConvertor fireCheckListUserCoConvertor;

    /**
     * 分页
     *
     * @param fireCheckListUserPageQry
     * @return
     */
    public PageResponse<FireCheckListUserCO> execute(FireCheckListUserPageQry fireCheckListUserPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(fireCheckListUserPageQry);
        PageResponse<FireCheckListUserDO> pageResponse = fireCheckListUserRepository.listPage(params);
        List<FireCheckListUserCO> examCenterCOS = fireCheckListUserCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

