package com.zcloud.primeport.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.primeport.command.convertor.PersonMessageCoConvertor;
import com.zcloud.primeport.dto.PersonMessagePageQry;
import com.zcloud.primeport.dto.clientobject.PersonMessageCO;
import com.zcloud.primeport.persistence.dataobject.PersonMessageDO;
import com.zcloud.primeport.persistence.repository.PersonMessageRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


/**
 * web-app
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:21
 */
@Component
@AllArgsConstructor
public class PersonMessageQueryExe {
    private final PersonMessageRepository personMessageRepository;
    private final PersonMessageCoConvertor personMessageCoConvertor;

    /**
     * 分页
     *
     * @param personMessagePageQry
     * @return
     */
    public PageResponse<PersonMessageCO> execute(PersonMessagePageQry personMessagePageQry) {
        Map<String, Object> parmas = PageQueryHelper.toHashMap(personMessagePageQry);
        PageResponse<PersonMessageDO> pageResponse = personMessageRepository.listPage(parmas);
        List<PersonMessageCO> examCenterCOS = personMessageCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

