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

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

/**
 * 模型服务 Mapper
 *
 * @author 华大大模型
 */
@Mapper
public interface ModelServiceMapper extends BaseMapperX<ModelServiceDO> {

    default PageResult<ModelServiceDO> selectPage(ModelServicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ModelServiceDO>()
                .likeIfPresent(ModelServiceDO::getServiceName, reqVO.getServiceName())
                .eqIfPresent(ModelServiceDO::getFineTuningTask, reqVO.getFineTuningTask())
                .eqIfPresent(ModelServiceDO::getCheckPoint, reqVO.getCheckPoint())
                .eqIfPresent(ModelServiceDO::getGpuType, reqVO.getGpuType())
                .eqIfPresent(ModelServiceDO::getGpuCount, reqVO.getGpuCount())
                .betweenIfPresent(ModelServiceDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ModelServiceDO::getStatus, reqVO.getStatus())
                .orderByDesc(ModelServiceDO::getId));
    }
    @Update("update llm_model_service set status = #{status} where id = #{id}")
    void updateStatus(@Param(value = "id")Long id,@Param(value = "status") Integer status);
}
