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

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.training.TrainingDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.llm.controller.admin.training.vo.*;

/**
 * 训练 Mapper
 *
 * @author 华大大模型
 */
@Mapper
public interface TrainingMapper extends BaseMapperX<TrainingDO> {

    default PageResult<TrainingDO> selectPage(TrainingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TrainingDO>()
                .likeIfPresent(TrainingDO::getModelName, reqVO.getModelName())
                .eqIfPresent(TrainingDO::getDescription, reqVO.getDescription())
                .eqIfPresent(TrainingDO::getTrainingEpochs, reqVO.getTrainingEpochs())
                .eqIfPresent(TrainingDO::getUseLora, reqVO.getUseLora())
                .eqIfPresent(TrainingDO::getTrainingBatchSize, reqVO.getTrainingBatchSize())
                .eqIfPresent(TrainingDO::getEvaluationBatchSize, reqVO.getEvaluationBatchSize())
                .eqIfPresent(TrainingDO::getGradientAccumulationSteps, reqVO.getGradientAccumulationSteps())
                .eqIfPresent(TrainingDO::getGpuCount, reqVO.getGpuCount())
                .eqIfPresent(TrainingDO::getLearningRate, reqVO.getLearningRate())
                .eqIfPresent(TrainingDO::getMaxLength, reqVO.getMaxLength())
                .eqIfPresent(TrainingDO::getCreatedAt, reqVO.getCreatedAt())
                .eqIfPresent(TrainingDO::getUpdatedAt, reqVO.getUpdatedAt())
                .orderByDesc(TrainingDO::getId));
    }

}