<?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.community.huiju.dao.TdImagesMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TdImages" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="image_url" property="imageUrl" jdbcType="VARCHAR" />
    <result column="uuid" property="uuid" jdbcType="INTEGER" />
    <result column="type" property="type" jdbcType="CHAR" />
    <result column="create_user" property="createUser" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, image_url, uuid, type, create_user, create_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from td_images
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from td_images
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TdImages" >
    insert into td_images (id, image_url, uuid, 
      type, create_user, create_time
      )
    values (#{id,jdbcType=INTEGER}, #{imageUrl,jdbcType=VARCHAR}, #{uuid,jdbcType=INTEGER}, 
      #{type,jdbcType=CHAR}, #{createUser,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TdImages" >
    insert into td_images
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="imageUrl != null" >
        image_url,
      </if>
      <if test="uuid != null" >
        uuid,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="createUser != null" >
        create_user,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="imageUrl != null" >
        #{imageUrl,jdbcType=VARCHAR},
      </if>
      <if test="uuid != null" >
        #{uuid,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        #{type,jdbcType=CHAR},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TdImages" >
    update td_images
    <set >
      <if test="imageUrl != null" >
        image_url = #{imageUrl,jdbcType=VARCHAR},
      </if>
      <if test="uuid != null" >
        uuid = #{uuid,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=CHAR},
      </if>
      <if test="createUser != null" >
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TdImages" >
    update td_images
    set image_url = #{imageUrl,jdbcType=VARCHAR},
      uuid = #{uuid,jdbcType=INTEGER},
      type = #{type,jdbcType=CHAR},
      create_user = #{createUser,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="getByUUIDAndByType" parameterType="map" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from td_images
    where uuid = #{uuid,jdbcType=INTEGER} and type = #{type,jdbcType=CHAR}
    order by create_time DESC
  </select>

  <delete id="deleteByUuidAndType" parameterType="map" >
    delete from td_images
    where uuid = #{uuid,jdbcType=INTEGER} and type = #{type,jdbcType=CHAR}
  </delete>

  <insert id="insertBatch" parameterType="list" >
    insert into td_images (image_url, uuid,
      type, create_user, create_time
      )
    values
    <foreach collection="list" item="item" index="index" separator="," >
      (#{item.imageUrl,jdbcType=VARCHAR}, #{item.uuid,jdbcType=INTEGER},
      #{item.type,jdbcType=CHAR}, #{item.createUser,jdbcType=INTEGER}, now()
      )
    </foreach>

  </insert>

  <delete id="deleteTdImages" parameterType="map" >
    delete from td_images
    where uuid = #{uuid,jdbcType=INTEGER} and type = #{type,jdbcType=CHAR}
  </delete>


  <select id="selectImages" resultMap="BaseResultMap" >
    SELECT
    *
    FROM
    td_images
    where uuid = #{uuid,jdbcType=INTEGER} and type = #{object,jdbcType=CHAR}
  </select>

</mapper>