package com.zcloud.primeport.command.query;

import com.alibaba.cola.dto.PageResponse;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.primeport.command.convertor.VehicleMessageCoConvertor;
import com.zcloud.primeport.dto.VehicleMessagePageQry;
import com.zcloud.primeport.dto.clientobject.VehicleMessageCO;
import com.zcloud.primeport.persistence.dataobject.VehicleMessageDO;
import com.zcloud.primeport.persistence.repository.VehicleMessageRepository;
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:28
 */
@Component
@AllArgsConstructor
public class VehicleMessageQueryExe {
    private final VehicleMessageRepository vehicleMessageRepository;
    private final VehicleMessageCoConvertor vehicleMessageCoConvertor;

    /**
     * 分页
     *
     * @param vehicleMessagePageQry
     * @return
     */
    public PageResponse<VehicleMessageCO> execute(VehicleMessagePageQry vehicleMessagePageQry) {
        Map<String, Object> parmas = PageQueryHelper.toHashMap(vehicleMessagePageQry);
        PageResponse<VehicleMessageDO> pageResponse = vehicleMessageRepository.listPage(parmas);
        List<VehicleMessageCO> examCenterCOS = vehicleMessageCoConvertor.converDOsToCOs(pageResponse.getData());
        return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
    }
}

