package com.gyee.alarm.mapper.auto;

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

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author shilin
 * @since 2024-10-28
 */
public interface ProEconAlarmPlanMapper extends BaseMapper<ProEconAlarmPlan> {



    @Select({"<script>",
            "select trouble_method from pro_econ_alarm_plan ",
            "<where>",
            " 1=1 ",

            "<if test='troubleMethod !=null  '>",
            "and name = #{name} ",
            "</if>",
            "<if test='troubleMethod !=null  '>",
            "and types = #{types} ",
            "</if>",
            "</where>",

            "</script>"})
    List<ProEconAlarmPlan> queryObject(@Param("name") String name,@Param("types") String types);


    @Update({"<script>",
            "update pro_econ_alarm_plan ",
            "<set>",
            "types = #{types},",
            "trouble_method = #{troubleMethod},",
            "process_method = #{processMethod},",
            "tools = #{tools}," ,
            "spare_parts = #{spareParts}," ,
            "name = #{name}" ,
            "</set>",
            "where id = #{id}",

            "</script>"})
    Integer updateByAlertruleId(ProEconAlarmPlan alertrule);


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


            "<if test='name !=null  '>",
            "and name like #{name}",
            "</if>",
            "<if test='types !=null  '>",
            "and types = #{types} ",
            "</if>",
            "</where>",
            " order by id  ",
            "</script>"})
    IPage<ProEconAlarmPlan> pageQueryAll(Page page,
                                         @Param("name") String name, @Param("types") String types);


}
