<?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.pcloud.book.custom.mapper.CustomTimeControlReplyMapper" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.custom.entity.CustomTimeControlReply" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="custom_time_control_id" property="customTimeControlId" jdbcType="INTEGER" />
    <result column="sub_type" property="subType" jdbcType="INTEGER" />
    <result column="reply_type" property="replyType" jdbcType="INTEGER" />
    <result column="content" property="content" jdbcType="VARCHAR" />
    <result column="description" property="description" jdbcType="VARCHAR" />
    <result column="link_url" property="linkUrl" jdbcType="VARCHAR" />
    <result column="pic_url" property="picUrl" jdbcType="VARCHAR" />
    <result column="serve_id" property="serveId" jdbcType="INTEGER" />
    <result column="serve_type" property="serveType" jdbcType="VARCHAR" />
    <result column="resource_id" property="resourceId" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, custom_time_control_id, sub_type, reply_type, content, description, link_url, 
    pic_url, serve_id, serve_type, resource_id, create_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from custom_time_control_reply
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from custom_time_control_reply
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply" >
    insert into custom_time_control_reply (id, custom_time_control_id, sub_type, 
      reply_type, content, description, 
      link_url, pic_url, serve_id, 
      serve_type, resource_id, create_time
      )
    values (#{id,jdbcType=INTEGER}, #{customTimeControlId,jdbcType=INTEGER}, #{subType,jdbcType=INTEGER}, 
      #{replyType,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, 
      #{linkUrl,jdbcType=VARCHAR}, #{picUrl,jdbcType=VARCHAR}, #{serveId,jdbcType=INTEGER}, 
      #{serveType,jdbcType=VARCHAR}, #{resourceId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply" >
    insert into custom_time_control_reply
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="customTimeControlId != null" >
        custom_time_control_id,
      </if>
      <if test="subType != null" >
        sub_type,
      </if>
      <if test="replyType != null" >
        reply_type,
      </if>
      <if test="content != null" >
        content,
      </if>
      <if test="description != null" >
        description,
      </if>
      <if test="linkUrl != null" >
        link_url,
      </if>
      <if test="picUrl != null" >
        pic_url,
      </if>
      <if test="serveId != null" >
        serve_id,
      </if>
      <if test="serveType != null" >
        serve_type,
      </if>
      <if test="resourceId != null" >
        resource_id,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="customTimeControlId != null" >
        #{customTimeControlId,jdbcType=INTEGER},
      </if>
      <if test="subType != null" >
        #{subType,jdbcType=INTEGER},
      </if>
      <if test="replyType != null" >
        #{replyType,jdbcType=INTEGER},
      </if>
      <if test="content != null" >
        #{content,jdbcType=VARCHAR},
      </if>
      <if test="description != null" >
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="linkUrl != null" >
        #{linkUrl,jdbcType=VARCHAR},
      </if>
      <if test="picUrl != null" >
        #{picUrl,jdbcType=VARCHAR},
      </if>
      <if test="serveId != null" >
        #{serveId,jdbcType=INTEGER},
      </if>
      <if test="serveType != null" >
        #{serveType,jdbcType=VARCHAR},
      </if>
      <if test="resourceId != null" >
        #{resourceId,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <insert id="batchInsert" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply">
    insert into custom_time_control_reply (custom_time_control_id, sub_type,
    reply_type, content, description,
    link_url, pic_url, serve_id,
    serve_type, resource_id, create_time
    )
    values
    <foreach collection="list" item="item" index="index" separator=",">
    (#{item.customTimeControlId,jdbcType=INTEGER}, #{item.subType,jdbcType=INTEGER},
    #{item.replyType,jdbcType=INTEGER}, #{item.content,jdbcType=VARCHAR}, #{item.description,jdbcType=VARCHAR},
    #{item.linkUrl,jdbcType=VARCHAR}, #{item.picUrl,jdbcType=VARCHAR}, #{item.serveId,jdbcType=INTEGER},
    #{item.serveType,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=INTEGER}, now()
    )
    </foreach>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.custom.entity.CustomTimeControlReply" >
    update custom_time_control_reply
    <set >
      <if test="customTimeControlId != null" >
        custom_time_control_id = #{customTimeControlId,jdbcType=INTEGER},
      </if>
      <if test="subType != null" >
        sub_type = #{subType,jdbcType=INTEGER},
      </if>
      <if test="replyType != null" >
        reply_type = #{replyType,jdbcType=INTEGER},
      </if>
      <if test="content != null" >
        content = #{content,jdbcType=VARCHAR},
      </if>
      <if test="description != null" >
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="linkUrl != null" >
        link_url = #{linkUrl,jdbcType=VARCHAR},
      </if>
      <if test="picUrl != null" >
        pic_url = #{picUrl,jdbcType=VARCHAR},
      </if>
      <if test="serveId != null" >
        serve_id = #{serveId,jdbcType=INTEGER},
      </if>
      <if test="serveType != null" >
        serve_type = #{serveType,jdbcType=VARCHAR},
      </if>
      <if test="resourceId != null" >
        resource_id = #{resourceId,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.pcloud.book.custom.entity.CustomTimeControlReply" >
    update custom_time_control_reply
    set custom_time_control_id = #{customTimeControlId,jdbcType=INTEGER},
      sub_type = #{subType,jdbcType=INTEGER},
      reply_type = #{replyType,jdbcType=INTEGER},
      content = #{content,jdbcType=VARCHAR},
      description = #{description,jdbcType=VARCHAR},
      link_url = #{linkUrl,jdbcType=VARCHAR},
      pic_url = #{picUrl,jdbcType=VARCHAR},
      serve_id = #{serveId,jdbcType=INTEGER},
      serve_type = #{serveType,jdbcType=VARCHAR},
      resource_id = #{resourceId,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="getSubscribeReplyList" parameterType="integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    custom_time_control_reply
    where
    custom_time_control_id = #{_parameter}
    and
    sub_type = 1
  </select>

  <select id="getUnSubscribeReplyList" parameterType="integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    custom_time_control_reply
    where
    custom_time_control_id = #{_parameter}
    and
    sub_type = 2
  </select>

  <delete id="deleteByCustomTimeControlId" parameterType="integer">
    delete
    from
    custom_time_control_reply
    where
    custom_time_control_id = #{id}
  </delete>
</mapper>