package com.cf.imes.module.executor.service.orderImport;

import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.executor.controller.admin.orderImportTask.vo.OrderImportTaskPageReqVO;
import com.cf.imes.module.executor.controller.admin.orderImportTask.vo.OrderImportTaskRespVO;
import com.cf.imes.module.executor.dal.dataobject.orderImport.OrderImportTaskDO;
import com.cf.imes.module.executor.dal.mysql.orderImport.OrderImportTaskMapper;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;

/**
 * @author Gqr
 * @since 2025/5/13 16:41
 */
@Service
public class OrderImportTaskServiceImpl implements OrderImportTaskService {
    @Resource
    private OrderImportTaskMapper orderImportTaskMapper;

    @Override
    public PageResult<OrderImportTaskRespVO> getPage(OrderImportTaskPageReqVO pageReqVO) {
        LambdaQueryWrapperX<OrderImportTaskDO> queryWrapper = new LambdaQueryWrapperX<OrderImportTaskDO>()
                .eq(OrderImportTaskDO::getOrganId, OrganContextHolder.getOrganId())
                .eqIfPresent(OrderImportTaskDO::getOrderId, pageReqVO.getOrderId())
                .betweenIfPresent(OrderImportTaskDO::getCreateTime, pageReqVO.getCreateTime())
                .eqIfPresent(OrderImportTaskDO::getFileName, pageReqVO.getFileName())
                .orderByDesc(OrderImportTaskDO::getCreateTime);
        return BeanUtils.toBean(orderImportTaskMapper.selectPage(pageReqVO, queryWrapper), OrderImportTaskRespVO.class);
    }


}
