package com.chushang.inspection.project.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chushang.common.core.util.StringUtils;
import com.chushang.inspection.project.po.PollingTask;

/**
  * @auther: zhao
  * @date: 2024/6/18 15:39
  */
public interface PollingTaskMapper extends BaseMapper<PollingTask> {
    default Integer childMaxIndex(String index, int level){
        QueryWrapper<PollingTask> taskSql = new QueryWrapper<>();
        taskSql.select("max(search_index) AS search_index").lambda()
                .likeRight(StringUtils.isNotBlank(index), PollingTask::getSearchNum,index)
                .eq(PollingTask::getLevel, level);
        PollingTask pollingTask = selectOne(taskSql);
        if (null == pollingTask) return null;
        // 此处为null
        return pollingTask.getSearchIndex();
    }
}
