<?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.dao.EarlyWarningMapper" >
  <resultMap id="BaseResultMap" type="com.entity.EarlyWarning" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="btype" property="btype" jdbcType="VARCHAR" />
    <result column="uid" property="uid" jdbcType="INTEGER" />
    <result column="status" property="status" jdbcType="VARCHAR" />
    <result column="pubtime" property="pubtime" jdbcType="TIMESTAMP" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.entity.EarlyWarning" extends="BaseResultMap" >
    <result column="note" property="note" jdbcType="LONGVARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, `name`, btype, `uid`, `status`, pubtime
  </sql>
  <sql id="Blob_Column_List" >
    note
  </sql>
  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from early_warning
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from early_warning
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.entity.EarlyWarning" >
    insert into early_warning (id, `name`, btype, 
      `uid`, `status`, pubtime, 
      note)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{btype,jdbcType=VARCHAR}, 
      #{uid,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR}, #{pubtime,jdbcType=TIMESTAMP}, 
      #{note,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.entity.EarlyWarning" >
    insert into early_warning
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="name != null" >
        `name`,
      </if>
      <if test="btype != null" >
        btype,
      </if>
      <if test="uid != null" >
        `uid`,
      </if>
      <if test="status != null" >
        `status`,
      </if>
      <if test="pubtime != null" >
        pubtime,
      </if>
      <if test="note != null" >
        note,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="btype != null" >
        #{btype,jdbcType=VARCHAR},
      </if>
      <if test="uid != null" >
        #{uid,jdbcType=INTEGER},
      </if>
      <if test="status != null" >
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="pubtime != null" >
        #{pubtime,jdbcType=TIMESTAMP},
      </if>
      <if test="note != null" >
        #{note,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.entity.EarlyWarning" >
    update early_warning
    <set >
      <if test="name != null" >
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="btype != null" >
        btype = #{btype,jdbcType=VARCHAR},
      </if>
      <if test="uid != null" >
        `uid` = #{uid,jdbcType=INTEGER},
      </if>
      <if test="status != null" >
        `status` = #{status,jdbcType=VARCHAR},
      </if>
      <if test="pubtime != null" >
        pubtime = #{pubtime,jdbcType=TIMESTAMP},
      </if>
      <if test="note != null" >
        note = #{note,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.entity.EarlyWarning" >
    update early_warning
    set `name` = #{name,jdbcType=VARCHAR},
      btype = #{btype,jdbcType=VARCHAR},
      `uid` = #{uid,jdbcType=INTEGER},
      `status` = #{status,jdbcType=VARCHAR},
      pubtime = #{pubtime,jdbcType=TIMESTAMP},
      note = #{note,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.entity.EarlyWarning" >
    update early_warning
    set `name` = #{name,jdbcType=VARCHAR},
      btype = #{btype,jdbcType=VARCHAR},
      `uid` = #{uid,jdbcType=INTEGER},
      `status` = #{status,jdbcType=VARCHAR},
      pubtime = #{pubtime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>








  <select id="getCount" parameterType="java.util.Map" resultType="int">
    select count(*) from early_warning where 1=1
    <if test="name != null">
      and name like concat('%',#{name,jdbcType=VARCHAR},'%')
    </if>
    <if test="btype != null">
      and btype = #{btype,jdbcType=VARCHAR}
    </if>
    <if test="uid != null">
      and `uid` = #{uid,jdbcType=INTEGER}
    </if>

  </select>
  <select id="getAll" parameterType="java.util.Map" resultMap="ResultMapWithBLOBs">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from early_warning where 1=1
    <if test="name != null">
      and name like concat('%',#{name,jdbcType=VARCHAR},'%')
    </if>
    <if test="btype != null">
      and btype = #{btype,jdbcType=VARCHAR}
    </if>
    <if test="uid != null">
      and `uid` = #{uid,jdbcType=INTEGER}
    </if>
    order by id desc
  </select>




  <select id="getByPage" parameterType="java.util.Map" resultMap="ResultMapWithBLOBs">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from early_warning where 1=1
    <if test="name != null">
      and name like concat('%',#{name,jdbcType=VARCHAR},'%')
    </if>
    <if test="btype != null">
      and btype = #{btype,jdbcType=VARCHAR}
    </if>
    <if test="uid != null">
      and `uid` = #{uid,jdbcType=INTEGER}
    </if>
    order by id desc
    <if test="pageno!=null and pageSize!=null">
      limit #{pageno},#{pageSize}
    </if>
  </select>
</mapper>