package com.zcloud.primeport.persistence.repository.impl;

import com.alibaba.cola.dto.PageResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jjb.saas.framework.repository.common.PageHelper;
import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl;
import com.zcloud.primeport.persistence.dataobject.VehicleMessageDO;
import com.zcloud.primeport.persistence.mapper.VehicleMessageMapper;
import com.zcloud.primeport.persistence.repository.VehicleMessageRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;
import com.zcloud.gbscommon.utils.Query;
import com.zcloud.gbscommon.utils.PageQueryHelper;

/**
 * web-infrastructure
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:28
 */
@Service
@RequiredArgsConstructor
public class VehicleMessageRepositoryImpl extends BaseRepositoryImpl<VehicleMessageMapper, VehicleMessageDO> implements VehicleMessageRepository {
    private final VehicleMessageMapper vehicleMessageMapper;

    @Override
    public PageResponse<VehicleMessageDO> listPage(Map<String, Object> params) {
        IPage<VehicleMessageDO> iPage = new Query<VehicleMessageDO>().getPage(params);
        QueryWrapper<VehicleMessageDO> queryWrapper = new QueryWrapper<>();
        queryWrapper = PageQueryHelper.createPageQueryWrapper(queryWrapper, params);
        queryWrapper.orderByDesc("create_time");
        IPage<VehicleMessageDO> result = vehicleMessageMapper.selectPage(iPage, queryWrapper);
        return PageHelper.pageToResponse(result, result.getRecords());
    }
}

