<?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.rightsSetting.mapper.RightsReadTypeMapper" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsReadType" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="rights_setting_id" property="rightsSettingId" jdbcType="BIGINT" />
    <result column="read_type" property="readType" jdbcType="INTEGER" />
    <result column="description" property="description" jdbcType="VARCHAR" />
    <result column="learning_length" property="learningLength" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
    <result column="read_type_name" property="readTypeName" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, rights_setting_id, read_type, description, learning_length, create_time, update_time,read_type_name
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    from rights_read_type
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="getByRightsSettingId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from rights_read_type
    where rights_setting_id = #{rightsSettingId,jdbcType=BIGINT}
    ORDER BY read_type ASC
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from rights_read_type
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByRightsSettingId" parameterType="long">
    delete
    from
    rights_read_type
    where
    rights_setting_id = #{rightsSettingId}
  </delete>
  <insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsReadType" >
    insert into rights_read_type (id, rights_setting_id, read_type, 
      description, learning_length, create_time, 
      update_time)
    values (#{id,jdbcType=BIGINT}, #{rightsSettingId,jdbcType=BIGINT}, #{readType,jdbcType=INTEGER}, 
      #{description,jdbcType=VARCHAR}, #{learningLength,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsReadType" >
    insert into rights_read_type
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="rightsSettingId != null" >
        rights_setting_id,
      </if>
      <if test="readType != null" >
        read_type,
      </if>
      <if test="description != null" >
        description,
      </if>
      <if test="learningLength != null" >
        learning_length,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=BIGINT},
      </if>
      <if test="rightsSettingId != null" >
        #{rightsSettingId,jdbcType=BIGINT},
      </if>
      <if test="readType != null" >
        #{readType,jdbcType=INTEGER},
      </if>
      <if test="description != null" >
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="learningLength != null" >
        #{learningLength,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsReadType">
    insert into rights_read_type (rights_setting_id, read_type,
    description, learning_length, create_time, update_time,read_type_name)
    values
    <foreach collection="list" item="item" index="index" separator=",">
    ( #{item.rightsSettingId,jdbcType=BIGINT}, #{item.readType,jdbcType=INTEGER},
    #{item.description,jdbcType=VARCHAR}, #{item.learningLength,jdbcType=INTEGER},now(), now(), #{item.readTypeName,jdbcType=VARCHAR})
    </foreach>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsReadType" >
    update rights_read_type
    <set >
      <if test="rightsSettingId != null" >
        rights_setting_id = #{rightsSettingId,jdbcType=BIGINT},
      </if>
      <if test="readType != null" >
        read_type = #{readType,jdbcType=INTEGER},
      </if>
      <if test="description != null" >
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="learningLength != null" >
        learning_length = #{learningLength,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.pcloud.book.rightsSetting.entity.RightsReadType" >
    update rights_read_type
    set rights_setting_id = #{rightsSettingId,jdbcType=BIGINT},
      read_type = #{readType,jdbcType=INTEGER},
      description = #{description,jdbcType=VARCHAR},
      learning_length = #{learningLength,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>