<?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.fdage.dao.base.TbCollectionMapper">
  <resultMap id="BaseResultMap" type="com.fdage.pojo.TbCollection">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="type_id" jdbcType="BIGINT" property="typeId" />
    <result column="time_id" jdbcType="BIGINT" property="timeId" />
    <result column="num" jdbcType="VARCHAR" property="num" />
    <result column="discovery_time" jdbcType="TIMESTAMP" property="discoveryTime" />
    <result column="repair_time" jdbcType="TIMESTAMP" property="repairTime" />
    <result column="venue" jdbcType="VARCHAR" property="venue" />
    <result column="unity_pic" jdbcType="VARCHAR" property="unityPic" />
    <result column="unity_url" jdbcType="VARCHAR" property="unityUrl" />
    <result column="pic" jdbcType="VARCHAR" property="pic" />
    <result column="model_url" jdbcType="VARCHAR" property="modelUrl" />
    <result column="content_url" jdbcType="VARCHAR" property="contentUrl" />
    <result column="state" jdbcType="INTEGER" property="state" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="like_num" jdbcType="BIGINT" property="likeNum" />
    <result column="open_num" jdbcType="BIGINT" property="openNum" />
    <result column="search_num" jdbcType="BIGINT" property="searchNum" />
    <result column="download_num" jdbcType="BIGINT" property="downloadNum" />
    <result column="icon" jdbcType="VARCHAR" property="icon" />
    <result column="dir_code" jdbcType="VARCHAR" property="dirCode" />
    <result column="visit" jdbcType="BIGINT" property="visit" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.fdage.pojo.TbCollection">
    <result column="description" jdbcType="LONGVARCHAR" property="description" />
  </resultMap>
  <sql id="Base_Column_List">
    id, name, type_id, time_id, num, dir_code, icon, discovery_time, repair_time, venue, pic, unity_pic, unity_url, model_url, content_url,
    state, create_time, like_num, open_num, search_num, download_num, type, url_list, qr_code
  </sql>
  <sql id="Blob_Column_List">
    description
  </sql>

  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from tb_collection
    where id = #{id,jdbcType=BIGINT}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from tb_collection
    where id = #{id,jdbcType=BIGINT}
  </delete>

  <select id="countVisit" resultType="java.lang.Long">
    SELECT SUM(visit) from tb_collection;
  </select>


  <update id="addVisit" parameterType="java.lang.Long">
    update tb_collection set visit = visit + 1  where id = #{id,jdbcType=BIGINT}
  </update>


  <insert id="insert" parameterType="com.fdage.pojo.TbCollection">
    insert into tb_collection (id, name, type_id, 
      time_id, num, discovery_time, repair_time,
      venue, pic, model_url, unity_pic, unity_url,
      content_url, state, create_time, icon, dir_code,
      description)
    values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{typeId,jdbcType=BIGINT},
      #{timeId,jdbcType=BIGINT}, #{num,jdbcType=VARCHAR}, #{discoveryTime,jdbcType=TIMESTAMP}, #{repairTime,jdbcType=TIMESTAMP},
      #{venue,jdbcType=VARCHAR}, #{pic,jdbcType=VARCHAR}, #{modelUrl,jdbcType=VARCHAR},
      #{unityPic,jdbcType=VARCHAR}, #{unityUrl,jdbcType=VARCHAR},
      #{contentUrl,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{icon,jdbcType=VARCHAR}, #{dirCode,jdbcType=VARCHAR},
      #{description,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.fdage.pojo.TbCollection">
    insert into tb_collection
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="typeId != null">
        type_id,
      </if>
      <if test="timeId != null">
        time_id,
      </if>
      <if test="num != null">
        num,
      </if>
      <if test="discoveryTime != null">
        discovery_time,
      </if>
      <if test="repairTime != null">
        repair_time,
      </if>
      <if test="venue != null">
        venue,
      </if>
      <if test="unityPic != null">
        unity_pic,
      </if>
      <if test="unityUrl != null">
        unity_url,
      </if>
      <if test="pic != null">
        pic,
      </if>
      <if test="modelUrl != null">
        model_url,
      </if>
      <if test="contentUrl != null">
        content_url,
      </if>
      <if test="state != null">
        state,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="description != null">
        description,
      </if>
      <if test="icon != null">
        icon,
      </if>
      <if test="dirCode != null">
        dir_code,
      </if>
      <if test="urlList != null">
        url_list ,
      </if>
      <if test="type != null">
        type ,
      </if>
      <if test="qrCode != null">
        qr_code ,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="typeId != null">
        #{typeId,jdbcType=BIGINT},
      </if>
      <if test="timeId != null">
        #{timeId,jdbcType=BIGINT},
      </if>
      <if test="num != null">
        #{num,jdbcType=VARCHAR},
      </if>
      <if test="discoveryTime != null">
        #{discoveryTime,jdbcType=TIMESTAMP},
      </if>
      <if test="repairTime != null">
        #{repairTime,jdbcType=TIMESTAMP},
      </if>
      <if test="venue != null">
        #{venue,jdbcType=VARCHAR},
      </if>
      <if test="unityPic != null">
        #{unityPic,jdbcType=VARCHAR},
      </if>
      <if test="unityUrl != null">
        #{unityUrl,jdbcType=VARCHAR},
      </if>
      <if test="pic != null">
        #{pic,jdbcType=VARCHAR},
      </if>
      <if test="modelUrl != null">
        #{modelUrl,jdbcType=VARCHAR},
      </if>
      <if test="contentUrl != null">
        #{contentUrl,jdbcType=VARCHAR},
      </if>
      <if test="state != null">
        #{state,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="description != null">
        #{description,jdbcType=LONGVARCHAR},
      </if>
      <if test="icon != null">
        #{icon,jdbcType=VARCHAR},
      </if>
      <if test="dirCode != null">
        #{dirCode,jdbcType=VARCHAR},
      </if>

      <if test="urlList != null">
        #{urlList,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="qrCode != null">
        #{qrCode,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.fdage.pojo.TbCollection">
    update tb_collection
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="typeId != null">
        type_id = #{typeId,jdbcType=BIGINT},
      </if>
      <if test="timeId != null">
        time_id = #{timeId,jdbcType=BIGINT},
      </if>
      <if test="num != null">
        num = #{num,jdbcType=VARCHAR},
      </if>
      <if test="discoveryTime != null">
        discovery_time = #{discoveryTime,jdbcType=TIMESTAMP},
      </if>
      <if test="repairTime != null">
        repair_time = #{repairTime,jdbcType=TIMESTAMP},
      </if>
      <if test="venue != null">
        venue = #{venue,jdbcType=VARCHAR},
      </if>
      <if test="unityPic != null">
        unity_pic = #{unityPic,jdbcType=VARCHAR},
      </if>
      <if test="unityUrl != null">
        unity_url = #{unityUrl,jdbcType=VARCHAR},
      </if>
      <if test="pic != null">
        pic = #{pic,jdbcType=VARCHAR},
      </if>
      <if test="modelUrl != null">
        model_url = #{modelUrl,jdbcType=VARCHAR},
      </if>
      <if test="contentUrl != null">
        content_url = #{contentUrl,jdbcType=VARCHAR},
      </if>
      <if test="state != null">
        state = #{state,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=LONGVARCHAR},
      </if>
      <if test="icon != null">
        icon = #{icon,jdbcType=VARCHAR},
      </if>
      <if test="dirCode != null">
        dir_code = #{dirCode,jdbcType=VARCHAR},
      </if>
      <if test="urlList != null">
        url_list = #{urlList,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=VARCHAR},
      </if>
      <if test="qrCode != null">
        qr_code = #{qrCode,jdbcType=VARCHAR},
      </if>

    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.fdage.pojo.TbCollection">
    update tb_collection
    set name = #{name,jdbcType=VARCHAR},
      type_id = #{typeId,jdbcType=BIGINT},
      time_id = #{timeId,jdbcType=BIGINT},
      num = #{num,jdbcType=VARCHAR},
      discovery_time = #{discoveryTime,jdbcType=TIMESTAMP},
      repair_time = #{repairTime,jdbcType=TIMESTAMP},
      venue = #{venue,jdbcType=VARCHAR},
      unity_pic = #{unityPic,jdbcType=VARCHAR},
      unity_url = #{unityUrl,jdbcType=VARCHAR},
      pic = #{pic,jdbcType=VARCHAR},
      model_url = #{modelUrl,jdbcType=VARCHAR},
      content_url = #{contentUrl,jdbcType=VARCHAR},
      state = #{state,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      icon = #{icon,jdbcType=VARCHAR},
      dir_code = #{dirCode,jdbcType=VARCHAR},
      description = #{description,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fdage.pojo.TbCollection">
    update tb_collection
    set name = #{name,jdbcType=VARCHAR},
      type_id = #{typeId,jdbcType=BIGINT},
      time_id = #{timeId,jdbcType=BIGINT},
      num = #{num,jdbcType=VARCHAR},
      discovery_time = #{discoveryTime,jdbcType=TIMESTAMP},
      repair_time = #{repairTime,jdbcType=TIMESTAMP},
      venue = #{venue,jdbcType=VARCHAR},
      unity_pic = #{unityPic,jdbcType=VARCHAR},
      unity_url = #{unityUrl,jdbcType=VARCHAR},
      pic = #{pic,jdbcType=VARCHAR},
      model_url = #{modelUrl,jdbcType=VARCHAR},
      content_url = #{contentUrl,jdbcType=VARCHAR},
      state = #{state,jdbcType=INTEGER},
       icon = #{icon,jdbcType=VARCHAR},
      dir_code = #{dirCode,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>