package com.zcloud.domain.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.domain.command.convertor.ProjectTaskInfoCoConvertor;
import com.zcloud.domain.dto.ProjectTaskInfoPageQry;
import com.zcloud.domain.dto.clientobject.ProjectTaskInfoCO;
import com.zcloud.domain.persistence.dataobject.ProjectTaskInfoDO;
import com.zcloud.domain.persistence.repository.ProjectTaskInfoRepository;
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:29
 */
@Component
@AllArgsConstructor
public class ProjectTaskInfoQueryExe {
    private final ProjectTaskInfoRepository projectTaskInfoRepository;
    private final ProjectTaskInfoCoConvertor projectTaskInfoCoConvertor;

    /**
     * 分页
     *
     * @param projectTaskInfoPageQry
     * @return
     */
    public PageResponse<ProjectTaskInfoCO> execute(ProjectTaskInfoPageQry projectTaskInfoPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(projectTaskInfoPageQry);
        PageResponse<ProjectTaskInfoDO> pageResponse = projectTaskInfoRepository.listPage(params);
        List<ProjectTaskInfoCO> examCenterCOS = projectTaskInfoCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

