<?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.EmergencyResourcesMapper" >
  <resultMap id="BaseResultMap" type="com.entity.EmergencyResources" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="btype" property="btype" jdbcType="VARCHAR" />
    <result column="fid" property="fid" jdbcType="INTEGER" />
    <result column="img" property="img" jdbcType="VARCHAR" />
    <result column="pubtime" property="pubtime" jdbcType="TIMESTAMP" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.entity.EmergencyResources" extends="BaseResultMap" >
    <result column="note" property="note" jdbcType="LONGVARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, `name`, btype, fid, img, 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 emergency_resources
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from emergency_resources
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.entity.EmergencyResources" >
    insert into emergency_resources (id, `name`, btype, 
      fid, img, pubtime, 
      note)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{btype,jdbcType=VARCHAR}, 
      #{fid,jdbcType=INTEGER}, #{img,jdbcType=VARCHAR}, #{pubtime,jdbcType=TIMESTAMP}, 
      #{note,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.entity.EmergencyResources" >
    insert into emergency_resources
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="name != null" >
        `name`,
      </if>
      <if test="btype != null" >
        btype,
      </if>
      <if test="fid != null" >
        fid,
      </if>
      <if test="img != null" >
        img,
      </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="fid != null" >
        #{fid,jdbcType=INTEGER},
      </if>
      <if test="img != null" >
        #{img,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.EmergencyResources" >
    update emergency_resources
    <set >
      <if test="name != null" >
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="btype != null" >
        btype = #{btype,jdbcType=VARCHAR},
      </if>
      <if test="fid != null" >
        fid = #{fid,jdbcType=INTEGER},
      </if>
      <if test="img != null" >
        img = #{img,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.EmergencyResources" >
    update emergency_resources
    set `name` = #{name,jdbcType=VARCHAR},
      btype = #{btype,jdbcType=VARCHAR},
      fid = #{fid,jdbcType=INTEGER},
      img = #{img,jdbcType=VARCHAR},
      pubtime = #{pubtime,jdbcType=TIMESTAMP},
      note = #{note,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.entity.EmergencyResources" >
    update emergency_resources
    set `name` = #{name,jdbcType=VARCHAR},
      btype = #{btype,jdbcType=VARCHAR},
      fid = #{fid,jdbcType=INTEGER},
      img = #{img,jdbcType=VARCHAR},
      pubtime = #{pubtime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>







  <select id="getCount" parameterType="java.util.Map" resultType="int">
    select count(*) from emergency_resources 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="fid != null">
      and  fid = #{fid,jdbcType=INTEGER}
    </if>

  </select>


  <select id="getAllNotFid" parameterType="java.util.Map" resultMap="ResultMapWithBLOBs">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from emergency_resources 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="fid != null">
      and fid = #{fid,jdbcType=INTEGER}
    </if>
    order by id desc
  </select>

  <select id="getAll" parameterType="java.util.Map" resultMap="ResultMapWithBLOBs">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from emergency_resources 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="fid != null">
      and fid = #{fid,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 emergency_resources 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="fid != null">
      and  fid = #{fid,jdbcType=INTEGER}
    </if>
    order by id desc
    <if test="pageno!=null and pageSize!=null">
      limit #{pageno},#{pageSize}
    </if>
  </select>
</mapper>