package com.zcloud.domain.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.domain.command.convertor.ProjectTaskScoreInfoCoConvertor;
import com.zcloud.domain.dto.ProjectTaskScoreInfoPageQry;
import com.zcloud.domain.dto.clientobject.ProjectTaskScoreInfoCO;
import com.zcloud.domain.persistence.dataobject.ProjectTaskScoreInfoDO;
import com.zcloud.domain.persistence.repository.ProjectTaskScoreInfoRepository;
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-27 11:30:46
 */
@Component
@AllArgsConstructor
public class ProjectTaskScoreInfoQueryExe {
    private final ProjectTaskScoreInfoRepository projectTaskScoreInfoRepository;
    private final ProjectTaskScoreInfoCoConvertor projectTaskScoreInfoCoConvertor;

    /**
     * 分页
     *
     * @param projectTaskScoreInfoPageQry
     * @return
     */
    public PageResponse<ProjectTaskScoreInfoCO> execute(ProjectTaskScoreInfoPageQry projectTaskScoreInfoPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(projectTaskScoreInfoPageQry);
        PageResponse<ProjectTaskScoreInfoDO> pageResponse = projectTaskScoreInfoRepository.listPage(params);
        List<ProjectTaskScoreInfoCO> examCenterCOS = projectTaskScoreInfoCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

