package com.gyee.alarm.mapper.auto;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gyee.alarm.model.auto.ProEconAlarmConfiguration;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gyee.alarm.model.auto.ProEconAlarmRule;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 报警配置表 Mapper 接口
 * </p>
 *
 * @author shilin
 * @since 2023-06-19
 */
public interface ProEconAlarmConfigurationMapper extends BaseMapper<ProEconAlarmConfiguration> {


    @Select({"<script>",
            "select * from pro_econ_alarm_configuration ",
            "<where>",
            " 1=1 ",
            "<if test='wpId !=null  '>",
            "and station_id = #{wpId} ",
            "</if>",
            "<if test='description !=null  '>",
            "and description like #{description} ",
            "</if>",
            "<if test='modelId !=null  '>",
            "and model_id = #{modelId} ",
            "</if>",
            "<if test='alarmType !=null  '>",
            "and alarm_type = #{alarmType} ",
            "</if>",
            "</where>",
            " order by id ",
            "</script>"})
    IPage<ProEconAlarmConfiguration> pageQueryAll(Page page,
                                         @Param("description") String description,
                                         @Param("wpId") String wpId,
                                         @Param("modelId") String modelId,@Param("alarmType")String alarmType);


    @Select({"<script>",
            "select * from pro_econ_alarm_configuration ",
            "<where>",
            " 1=1 ",

            "<if test='wpId !=null  '>",
            "and station_id  = #{wpId} ",
            "</if>",
            "<if test='description !=null  '>",
            "and description = #{description} ",
            "</if>",
            "<if test='modelId !=null  '>",
            "and model_id = #{modelId} ",
            "</if>",
            "</where>",

            "</script>"})
    List<ProEconAlarmConfiguration> queryObject(@Param("description") String description,
                                       @Param("wpId") String wpId,
                                       @Param("modelId") String modelId);
}
