package org.jeecg.modules.newWarning.mapper;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.newWarning.entity.TabQi;
import org.jeecg.modules.newWarning.entity.WellDrilling;

import java.util.List;

@DS("yjDataSource")
@Mapper
public interface WellDrillingMapper extends BaseMapper<WellDrilling> {

    @Select({"select table_name from USER_TABLES"})
    List<String> tableNames();

    @Select(" select * from "+"\"${jhTableName}\""+"  ${ew.customSqlSegment} ")
    List<WellDrilling> selectListOrcale(@Param("jhTableName")String jhTableName, @Param("ew") QueryWrapper<WellDrilling> queryWrapper);

    /**
     * @param jhTableName
     * @param motion
     * @param operatingMode
     * @param queryWrapper
     */
    @Update("UPDATE "+"\"${jhTableName}\""+"  SET motion="+"'${motion}'"+",operating_mode="+"'${operatingMode}'"+"  ${ew.customSqlSegment}")
    void updateByTimeOrcale(@Param("jhTableName")String jhTableName,@Param("motion")String motion,
                            @Param("operatingMode")String operatingMode,@Param("ew") QueryWrapper<WellDrilling> queryWrapper);

    @Select("select * from  \"\"${jhTableName}\"\"  ${ew.customSqlSegment}")
    List<WellDrilling> selectList(@Param("jhTableName")String jhTableName, @Param("ew") QueryWrapper<WellDrilling> queryWrapper);

    @Select("select * from  \"\"${jhTableName}\"\" ${ew.customSqlSegment}")
    Page<WellDrilling> selectListPage(@Param("jhTableName")String jhTableName, @Param("ew") QueryWrapper<WellDrilling> queryWrapper, Page<WellDrilling> page);

    @Select("select * from  \"\"${jhTableName}\"\"  ${ew.customSqlSegment} Limit #{page},#{pageNo}")
    List<WellDrilling> selectListP(@Param("jhTableName")String jhTableName, @Param("ew") QueryWrapper<WellDrilling> queryWrapper,@Param("page")Integer page,@Param("pageNo")Integer pageNo);

    @Select("select * from  \"${jhTableName}\"  ${ew.customSqlSegment} LIMIT 1")
    WellDrilling selectOne(@Param("jhTableName")String jhTableName,@Param("ew") QueryWrapper<WellDrilling> queryWrapper);

    @Select("select * from   (select * from \"${jhTableName}\"  order by time desc ) where  rownum<2")
    WellDrilling selectOneOrcale(@Param("jhTableName")String jhTableName);

    @Select("select * from ( select * from  \"${jhTableName}\"  ${ew.customSqlSegment} )  where rownum<4 ")
    List<WellDrilling> selectListPOrcale(@Param("jhTableName")String jhTableName, @Param("ew") QueryWrapper<WellDrilling> queryWrapper);

    @Select("select * from   (select * from \"${jhTableName}\"  ${ew.customSqlSegment} ) where  rownum<2")
    WellDrilling selectWOneOrcale(@Param("jhTableName")String jhTableName, @Param("ew") QueryWrapper<WellDrilling> queryWrapper);
}
