package com.zcloud.domain.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.domain.command.convertor.ProjectTaskGroupUserCoConvertor;
import com.zcloud.domain.dto.ProjectTaskGroupUserPageQry;
import com.zcloud.domain.dto.clientobject.ProjectTaskGroupUserCO;
import com.zcloud.domain.persistence.dataobject.ProjectTaskGroupUserDO;
import com.zcloud.domain.persistence.repository.ProjectTaskGroupUserRepository;
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-29 11:28:09
 */
@Component
@AllArgsConstructor
public class ProjectTaskGroupUserQueryExe {
    private final ProjectTaskGroupUserRepository projectTaskGroupUserRepository;
    private final ProjectTaskGroupUserCoConvertor projectTaskGroupUserCoConvertor;

    /**
     * 分页
     *
     * @param projectTaskGroupUserPageQry
     * @return
     */
    public PageResponse<ProjectTaskGroupUserCO> execute(ProjectTaskGroupUserPageQry projectTaskGroupUserPageQry) {
        Map<String, Object> params = PageQueryHelper.toHashMap(projectTaskGroupUserPageQry);
        PageResponse<ProjectTaskGroupUserDO> pageResponse = projectTaskGroupUserRepository.listPage(params);
        List<ProjectTaskGroupUserCO> examCenterCOS = projectTaskGroupUserCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

