TaskSheduleMapper.xml 6.88 KB
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.monitor.mysql.mapper.TaskSheduleMapper">
    <resultMap id="BaseResultMap" type="com.model.TaskModel">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="alarm_interval" property="interval" jdbcType="INTEGER"/>
        <result column="relax_start_time" property="relaxStartTime" jdbcType="INTEGER"/>
        <result column="relax_end_time" property="relaxEndTime" jdbcType="INTEGER"/>
        <result column="time_flag" property="timeFlag" jdbcType="INTEGER"/>
        <result column="alarm_type" property="alarmType" jdbcType="INTEGER"/>
        <result column="alarm_num_flag" property="alarmNumFlag" jdbcType="INTEGER"/>
        <result column="is_run" property="isRun" jdbcType="INTEGER"/>
        <result column="is_on" property="isOn" jdbcType="INTEGER"/>
        <result column="continuous_alarm_times" property="alarmTimes" jdbcType="INTEGER"/>
        <result column="fields" property="fields" jdbcType="VARCHAR"/>
        <result column="tags" property="tags" jdbcType="VARCHAR"/>
        <result column="influxdbs" property="influxdbs" jdbcType="VARCHAR"/>
        <result column="influx_sql" property="influxSql" jdbcType="VARCHAR"/>
        <result column="mobile" property="mobile" jdbcType="VARCHAR"/>
        <result column="sms" property="sms" jdbcType="VARCHAR"/>
        <result column="type" property="type" jdbcType="VARCHAR"/>
        <result column="inf_database" property="database" jdbcType="VARCHAR"/>
        <result column="description" property="description" jdbcType="VARCHAR"/>
        <result column="last_time" property="lastTime"/>
        <result column="alarm_group_id" property="alarmGroupId" jdbcType="INTEGER"/>
        <result column="addsource" property="addSource" jdbcType="INTEGER"/>
        <result column="influx_sql_snd" property="influxSqlSnd" jdbcType="VARCHAR"/>
        <result column="eventname" property="eventName" jdbcType="VARCHAR"/>
        <result column="operation" property="operation" jdbcType="INTEGER"/>
        <result column="data_interval_times" property="dataIntervalTimes" jdbcType="INTEGER"/>
        <result column="alarm_channel" property="alarmChannel" jdbcType="VARCHAR"/>
    </resultMap>

    <select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
    select
      *
    from task_shedule
    where id = #{id,jdbcType=INTEGER}
  </select>

    <select id="selectAll" resultMap="BaseResultMap">
    select
      *
    from task_shedule
  </select>

    <select id="selectByPageWithSourceTask" resultMap="BaseResultMap">
    select
    *
    from task_shedule
    where addsource = #{params.addSource,jdbcType=INTEGER}
     <if test="params.eventName != null &amp;&amp; params.eventName != ''" >
            and  eventname like CONCAT('%',#{params.eventName,jdbcType=VARCHAR},'%' )
     </if>
     <if test="params.sms!=null &amp;&amp; params.sms != ''">
            and sms like CONCAT('%',#{params.sms,jdbcType=VARCHAR},'%')
     </if>
        order by id
        limit #{startIndex},#{pageSize}
  </select>

    <!--<select id="selectByPageWithSourceGateway" resultMap="BaseResultMap">
        select
        *
        from task_shedule
        where addsource = 1
        <if test="page.params.eventName != null &amp;&amp; page.params.eventName != ''" >
            and  eventname like CONCAT('%',#{page.params.eventName,jdbcType=VARCHAR},'%' )
        </if>
        order by id
        limit #{page.startIndex},#{page.pageSize}
    </select>-->

    <select id="selectCount" resultType="java.lang.Integer">
    select
    count(1)
    from task_shedule
    where addsource = #{params.addSource,jdbcType=INTEGER}
    <if test="params.eventName != null &amp;&amp; params.eventName != ''" >
        and eventname like  CONCAT('%',#{params.eventName,jdbcType=VARCHAR},'%' )
   </if>
   <if test="params.sms!=null &amp;&amp; params.sms != ''">
       and sms like CONCAT('%',#{params.sms,jdbcType=VARCHAR},'%')
   </if>

  </select>

    <delete id="deleteById" parameterType="java.lang.Integer">
    delete from task_shedule
    where id = #{id,jdbcType=INTEGER}
  </delete>

    <update id="updateByid" parameterType="com.model.TaskModel">
    update task_shedule
    set alarm_interval = #{interval,jdbcType=INTEGER},
    relax_start_time = #{relaxStartTime,jdbcType=INTEGER},
    time_flag = #{timeFlag,jdbcType=INTEGER},
    relax_end_time = #{relaxEndTime,jdbcType=INTEGER},
    alarm_type = #{alarmType,jdbcType=INTEGER},
    alarm_num_flag = #{alarmNumFlag,jdbcType=INTEGER},
    is_on = #{isOn,jdbcType=INTEGER},
    alarm_channel = #{alarmChannel,jdbcType=VARCHAR},
    fields = #{fields,jdbcType=VARCHAR},
    tags = #{tags,jdbcType=VARCHAR},
    influxdbs = #{influxdbs,jdbcType=VARCHAR},
    influx_sql = #{influxSql,jdbcType=VARCHAR},
    influx_sql_snd = #{influxSqlSnd,jdbcType=VARCHAR},
    mobile = #{mobile,jdbcType=VARCHAR},
    sms = #{sms,jdbcType=VARCHAR},
    type = #{type,jdbcType=VARCHAR},
    description = #{description,jdbcType=VARCHAR},
    inf_database = #{database,jdbcType=VARCHAR},
    alarm_group_id = #{alarmGroupId,jdbcType=INTEGER},
    eventname = #{eventName,jdbcType=INTEGER},
    operation = #{operation,jdbcType=INTEGER},
    data_interval_times = #{dataIntervalTimes,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>

    <insert id="insert" parameterType="com.model.TaskModel">
    insert into task_shedule
    (alarm_interval,
      relax_start_time,
      time_flag,
      relax_end_time,
      alarm_num_flag,
      alarm_type,
      is_on,
      alarm_channel,
      fields,
      tags,
      influxdbs,
      influx_sql,
      mobile,
      sms,
      type ,
      inf_database,
      description,
      alarm_group_id,
      addsource,
      influx_sql_snd,
      eventname,
      operation,
      data_interval_times)
    values
    (#{interval,jdbcType=INTEGER},
     #{relaxStartTime,jdbcType=INTEGER},
     #{timeFlag,jdbcType=INTEGER},
     #{relaxEndTime,jdbcType=INTEGER},
     #{alarmNumFlag,jdbcType=INTEGER},
     #{alarmType,jdbcType=INTEGER},
     #{isOn,jdbcType=INTEGER},
     #{alarmChannel,jdbcType=VARCHAR},
     #{fields,jdbcType=VARCHAR},
     #{tags,jdbcType=VARCHAR},
     #{influxdbs,jdbcType=VARCHAR},
     #{influxSql,jdbcType=VARCHAR},
     #{mobile,jdbcType=VARCHAR},
     #{sms,jdbcType=VARCHAR},
     #{type,jdbcType=VARCHAR},
     #{database,jdbcType=VARCHAR},
     #{description,jdbcType=VARCHAR},
     #{alarmGroupId,jdbcType=INTEGER},
     #{addSource,jdbcType=INTEGER},
     #{influxSqlSnd,jdbcType=VARCHAR},
     #{eventName,jdbcType=VARCHAR},
     #{operation,jdbcType=INTEGER},
     #{dataIntervalTimes,jdbcType=INTEGER}
      )
  </insert>

    <update id="updateLastTime" parameterType="java.lang.Integer">
        update task_shedule
        set last_time = now()
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>