package com.njcn.harmonic.service.upload.impl;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.harmonic.mapper.upload.RUploadDataLogMapper;
import com.njcn.harmonic.pojo.po.upload.RUploadDataLog;
import com.njcn.harmonic.service.upload.IRUploadDataLogService;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.pojo.param.BaseParam;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 调度算法执行结果记录表 服务实现类
 * </p>
 *
 * @author hongawen
 * @since 2024-06-06
 */
@Service
public class RUploadDataLogServiceImpl extends MppServiceImpl<RUploadDataLogMapper, RUploadDataLog> implements IRUploadDataLogService {

    @Override
    public Page<RUploadDataLog> getList(BaseParam baseParam) {
        LambdaQueryWrapper<RUploadDataLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.between(RUploadDataLog::getCreateTime,baseParam.getSearchBeginTime(),baseParam.getSearchEndTime())
                .orderByDesc(RUploadDataLog::getStatisticDate);
        if(StrUtil.isNotBlank(baseParam.getSearchValue())){
            lambdaQueryWrapper.eq(RUploadDataLog::getSmallType,Integer.parseInt(baseParam.getSearchValue()));
        }
        if(StrUtil.isNotBlank(baseParam.getSortBy())){
            lambdaQueryWrapper.eq(RUploadDataLog::getResult,Integer.parseInt(baseParam.getSortBy()));
        }
        return this.page(new Page<>(PageFactory.getPageNum(baseParam),PageFactory.getPageSize(baseParam)),lambdaQueryWrapper);
    }
}
