package com.fdkankan.platform.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fdkankan.platform.user.entity.IncrementLog;
import com.fdkankan.platform.user.mapper.IIncrementLogMapper;
import com.fdkankan.platform.user.request.RequestIncrement;
import com.fdkankan.platform.user.service.IIncrementLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2022-01-18
 */
@Service
public class IncrementLogServiceImpl extends ServiceImpl<IIncrementLogMapper, IncrementLog> implements IIncrementLogService {

    @Override
    public Page<IncrementLog> getPageByStatusAndNum(RequestIncrement param) {
        LambdaQueryWrapper<IncrementLog> queryWrapper = new LambdaQueryWrapper<>();

        if(StringUtils.isNotEmpty(param.getStartDate()) && StringUtils.isNotEmpty(param.getEndDate())){
            queryWrapper.between(IncrementLog::getCreateTime,param.getStartDate(),param.getEndDate());
        }
        if(StringUtils.isNotEmpty(param.getSearchKey())){
            queryWrapper.like(IncrementLog::getOperateUesr,param.getSearchKey());
        }
        queryWrapper.orderByDesc(IncrementLog::getId);
        return this.page(new Page<>(param.getPageNum(),param.getPageSize()),queryWrapper);
    }
}
