package cn.iocoder.yudao.module.llm.dal.mysql.finetuningtask;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.llm.dal.dataobject.finetuningtask.FineTuningTaskDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.llm.controller.admin.finetuningtask.vo.*;

/**
 * 模型调优 —— 微调任务 Mapper
 *
 * @author 华大大模型
 */
@Mapper
public interface FineTuningTaskMapper extends BaseMapperX<FineTuningTaskDO> {

    default PageResult<FineTuningTaskDO> selectPage(FineTuningTaskPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FineTuningTaskDO>()
                .likeIfPresent(FineTuningTaskDO::getTaskName, reqVO.getTaskName())
                .eqIfPresent(FineTuningTaskDO::getBaseModel, reqVO.getBaseModel())
                .eqIfPresent(FineTuningTaskDO::getTrainStage, reqVO.getTrainStage())
                .eqIfPresent(FineTuningTaskDO::getMethod, reqVO.getMethod())
                .eqIfPresent(FineTuningTaskDO::getTaskIntro, reqVO.getTaskIntro())
                .eqIfPresent(FineTuningTaskDO::getGpuType, reqVO.getGpuType())
                .eqIfPresent(FineTuningTaskDO::getGpuCount, reqVO.getGpuCount())
                .eqIfPresent(FineTuningTaskDO::getDataset, reqVO.getDataset())
                .eqIfPresent(FineTuningTaskDO::getLearningRate, reqVO.getLearningRate())
                .eqIfPresent(FineTuningTaskDO::getEpoch, reqVO.getEpoch())
                .eqIfPresent(FineTuningTaskDO::getCutoffLen, reqVO.getCutoffLen())
                .eqIfPresent(FineTuningTaskDO::getBatchSize, reqVO.getBatchSize())
                .eqIfPresent(FineTuningTaskDO::getGradientAccumulation, reqVO.getGradientAccumulation())
                .eqIfPresent(FineTuningTaskDO::getWarmup, reqVO.getWarmup())
                .eqIfPresent(FineTuningTaskDO::getLorayRank, reqVO.getLorayRank())
                .eqIfPresent(FineTuningTaskDO::getLorayScaleFactor, reqVO.getLorayScaleFactor())
                .eqIfPresent(FineTuningTaskDO::getLorayDropout, reqVO.getLorayDropout())
                .eqIfPresent(FineTuningTaskDO::getLorayModule, reqVO.getLorayModule())
                .eqIfPresent(FineTuningTaskDO::getDeepSpeedStage, reqVO.getDeepSpeedStage())
                .eqIfPresent(FineTuningTaskDO::getAccelerationMethod, reqVO.getAccelerationMethod())
                .eqIfPresent(FineTuningTaskDO::getDeepSpeedOffload, reqVO.getDeepSpeedOffload())
                .eqIfPresent(FineTuningTaskDO::getSaveInterval, reqVO.getSaveInterval())
                .betweenIfPresent(FineTuningTaskDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(FineTuningTaskDO::getStatus, reqVO.getStatus())
                .eq(FineTuningTaskDO::getDeleted, false)
                .orderByDesc(FineTuningTaskDO::getId));
    }

}